29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
SimpleDateFormat formatter =
new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now;
String str_date;
Timer timer;
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
get_con();
get_gps();
timer =
new
Timer(
true
);
timer.schedule(task,
0
,
1000
);
}
@Override
public
boolean
onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return
true
;
}
public
void
get_gps(){
lom = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
loc = lom.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if
(loc !=
null
) {
lat = loc.getLatitude();
lng = loc.getLongitude();
txt_lat.setText("纬度:" + String.valueOf(lat));
txt_lng.setText("经度:" + String.valueOf(lng));
}
else
{
txt_lat.setText("纬度:未知" );
txt_lng.setText("经度:未知" );
}
Criteria criteria =
new
Criteria();