-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainActivity.java
More file actions
44 lines (36 loc) · 1.24 KB
/
MainActivity.java
File metadata and controls
44 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package student8.example.com.clock_tok;
import android.app.Activity;
import android.app.AlarmManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Date;
public class MainActivity extends Activity {
Button btn;
TextView tv, tv2;
Date date = new Date();
AlarmManager am;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button);
tv = (TextView) findViewById(R.id.textView);
tv2 = (TextView) findViewById(R.id.textView2);
am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
am.setTime(date.getTime());
tv2.setText(date.toString());
date.setTime(date.getTime() + 10000);
tv.setText(date.toString());
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this, SecondActivity.class);
startActivity(i);
}
});
}
}