referring to the code below.. I got a class LocationService and have a variable latitude in it. I want use that variable in another class Post. How do I do that. Basically I want get the latitude and longitude which i get from there in the other class also.. As I want to post it on the server. So how do i do that.
LocationService.java
public class LocationService extends Service{
Context context;
WakeLock wl;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
public int onStartCommand(Intent intent, int flags, int startId) {
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
wl.acquire();
context = this;
final String who = intent.getStringExtra("who");
final LocationManager locMan = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
final LocationListener listener = new LocationListener(){
// start location changed
public void onLocationChanged(Location loc) {
double latitude = loc.getLatitude();
double longitude = loc.getLongitude();
......
......
}
Post.java
public class Post extends LocationService {
}
EDITED Post.java
public class Post extends LocationService {{
super.latitude = loc.getLatitude();
}
}
Will this get me the latitude from LocationService class to Post class..?