-
Notifications
You must be signed in to change notification settings - Fork 0
/
Location_class.java
81 lines (59 loc) · 2.13 KB
/
Location_class.java
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
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
72
73
74
75
76
77
78
79
80
81
package com.d_andaman;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
@SuppressLint("NewApi")
public class Location_class extends Activity {
Button btnShowLocation,stoplocation;
TextView lat,lat1;
TextView lon,lon1;
GPSTracker gps;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
ActionBar action = getActionBar();
action.setIcon(R.drawable.circle1);
action.setTitle("Location Manager");
btnShowLocation = (Button) findViewById(R.id.showlocation);
stoplocation=(Button)findViewById(R.id.stop);
lat=(TextView) findViewById(R.id.lat);
lon=(TextView) findViewById(R.id.lon);
// lat1=(TextView) findViewById(R.id.lat1);
// lon1=(TextView) findViewById(R.id.lon1);
btnShowLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// create class object
gps = new GPSTracker(Location_class.this);
// check if GPS enabled
if(gps.canGetLocation()){
double latitude = gps.getLatitude();
double longitude = gps.getLongitude();
String latstr=""+latitude;
String lonstr=""+longitude;
//new Map_service(getApplicationContext(),lat,lon).execute(latstr,lonstr);
lat.setText("LAT"+latstr);
lon.setText("LON"+lonstr);
//lat1.setText("LAT:"+latitude);
//lon1.setText("LON:"+longitude);
}else{
gps.showSettingsAlert();
}
}
});
stoplocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gps.stopUsingGPS();
Toast.makeText(getApplicationContext(),
"Service stoped", Toast.LENGTH_SHORT).show();
}
});
}
}