I try to retrieve Location updates in Service by network provider, but the updates doesn,t perform. My code looks like this:
public class TimeService extends Service{
LocationManager lm;
LocationListener ll = new LocationListener()
{
#Override
public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longtitude = location.getLongitude();
Intent inte =new Intent( TimeService.this, myAppWidgetProvider.class);
inte.setAction("action_location");
inte.putExtra("lat", latitude);
inte.putExtra("long", longtitude);
PendingIntent pinte = PendingIntent.getBroadcast(TimeService.this, 0, inte, 0);
try {
pinte.send();
} catch (CanceledException e) {
// TODO Auto-generated catch block
Log.d("sendPIException", ":-(");
}
Log.d("locReceived", "onLochanged");
}
#Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
}
};
Log "locReceived" in onLocationChanged doesn't appear i logcat
Following code responsible for Location in my Service, too:
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
this.registerReceiver(br, new IntentFilter(Intent.ACTION_TIME_TICK));
lm =(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, ll);
return super.onStartCommand(intent, flags, startId);
}
What's wrong in my code?
Criteria criteria = new Criteria();
String provider = lm.getBestProvider(criteria, false);
Location location = lm.getLastKnownLocation(provider);
lm.requestLocationUpdates(provider, 0, 0, ll);
if (location == null) {
Log.e("Impl", "Location not available");
}
Related
One of my android app needs to get gps positions, if the app is in destroy state. My app get gps positions currently when it is in running(active) and pause(background) modes. But when I destroyed my app, the service is running but the LocationListener onLocationChanged(Location location) not calling. How can I deal this type of issues?.
public class LocationFinder extends Service {
public static double lat, lng;
LocationManager locationManager;
public void onDestroy() {
super.onDestroy();
}
#Override
public void onCreate() {
super.onCreate();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Log.v("location", "===>location ed onStartCommand " + lat + "==>"
+ lng);
new Handler(Looper.getMainLooper()).post(new Runnable() {
#Override
public void run() {
getLocation();
}
});
return START_STICKY;
}
final LocationListener locationListener = new LocationListener() {
// this method is not called when we destroyed the app. i want to call this method even app is in destoyed.
public void onLocationChanged(Location location) {
updateWithNewLocation(location);
Toast.makeText(
getApplicationContext(),
"Location Finder : onLocation Changed "
+ location.getLatitude() + " "
+ location.getLongitude(), Toast.LENGTH_LONG)
.show();
}
public void onProviderDisabled(String provider) {
updateWithNewLocation(null);
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
};
public Location getLocation() {
Variables.writeLog("Enter into getLocation : \n", false);
String context = Context.LOCATION_SERVICE;
locationManager = (LocationManager) getSystemService(context);
Location location = null;
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
Log.v("Location", "Before");
if (locationManager != null) {
String provider = locationManager.getBestProvider(criteria, true);
boolean isGPSEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (provider != null) {
if (isGPSEnabled) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 10, 0,
locationListener);
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 10, 0,
locationListener);
if (location != null) {
updateWithNewLocation(location);
} else {
location = locationManager
.getLastKnownLocation(provider);
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider,
10, 0, locationListener);
}
} else {
location = locationManager
.getLastKnownLocation(provider);
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider, 10, 0,
locationListener);
}
} else {
location = locationManager.getLastKnownLocation(provider);
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider, 10, 0,
locationListener);
}
} else {
if (locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 10, 0,
locationListener);
} else if (locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 10, 0,
locationListener);
} else if (locationManager
.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)) {
locationManager.requestLocationUpdates(
LocationManager.PASSIVE_PROVIDER, 10, 0,
locationListener);
}
}
}
return location;
}
private void updateWithNewLocation(Location location) {
if (location != null) {
Log.v("location", "===>location ed " + lat);
lat = location.getLatitude();
lng = location.getLongitude();
Variables.writeLog("Lat :" + lat + " lng : " + lng, false);
}
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}
Hey you need to create background Service which will work in the background and do that job for you check those links
link 1
link 2
You can start this services when your activity is destroyed and the stop it when your app is resumed
You Have to run background service which will recieve locations using gps.
public class AndroidLocationServices extends Service {
WakeLock wakeLock;
private LocationManager locationManager;
public AndroidLocationServices() {
// TODO Auto-generated constructor stub
}
#Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
PowerManager pm = (PowerManager) getSystemService(this.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DoNotSleep");
// Toast.makeText(getApplicationContext(), "Service Created",
// Toast.LENGTH_SHORT).show();
Log.e("Google", "Service Created");
}
#Override
#Deprecated
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
new ToggleGPS(getApplicationContext()).turnGPSOn();
// Toast.makeText(getApplicationContext(), "Service Started",
// Toast.LENGTH_SHORT).show();
Log.e("Google", "Service Started");
locationManager = (LocationManager) getApplicationContext()
.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
5000, 5, listener);
}
private LocationListener listener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Log.e("Google", "Location Changed");
if (location == null)
return;
if (isConnectingToInternet(getApplicationContext())) {
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
try {
Log.e("latitude", location.getLatitude() + "");
Log.e("longitude", location.getLongitude() + "");
jsonObject.put("latitude", location.getLatitude());
jsonObject.put("longitude", location.getLongitude());
jsonArray.put(jsonObject);
Log.e("request", jsonArray.toString());
new LocationWebService().execute(new String[] {
Constants.TRACK_URL, jsonArray.toString() });
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
#Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
};
#Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
new ToggleGPS(getApplicationContext()).turnGPSOff();
wakeLock.release();
}
public static boolean isConnectingToInternet(Context _context) {
ConnectivityManager connectivity = (ConnectivityManager) _context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null)
for (int i = 0; i < info.length; i++)
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
return false;
}
}
I found this code in github. it works , I have used it in my appilcation.
GITHUB LINK
I'm writing an app that requests for location updates like this:
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, interval, 0, locationListener);
onLocationChanged gets invoked when device is on but when put into sleep it stops receiving further updates. I followed this thread but as I said - it doesn't work.
The listener is registered inside foreground service that needs to work all the time. I want to conserve battery by waking it from sleep only when I receive new location.
EDIT: of course everything works when I acquire wakelock in onCreate() method and release it in onDestroy() method for service but I don't want to do this.
If you want to use background task then use this service
public class LocationFinder extends Service {
public static double lat, lng;
LocationManager locationManager;
public void onDestroy() {
super.onDestroy();
if (locationManager != null && locationListener != null) {
locationManager.removeUpdates(locationListener);
}
}
#Override
public void onCreate() {
Log.v("location", "===>location ed onCreate " + lat);
super.onCreate();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Log.v("location", "===>location ed onStartCommand " + lat + "==>" + lng);
new Handler().post(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
getLocation();
}
});
return START_STICKY;
}
final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
updateWithNewLocation(location);
}
public void onProviderDisabled(String provider) {
updateWithNewLocation(null);
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
};
private void getLocation() {
String context = Context.LOCATION_SERVICE;
locationManager = (LocationManager) getSystemService(context);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
if (locationManager != null) {
String provider = locationManager.getBestProvider(criteria, true);
if (provider != null) {
Location location = locationManager.getLastKnownLocation(provider);
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider, 500, 50, locationListener);
} else {
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 500, 50, locationListener);
} else if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 50, locationListener);
} else if (locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 500, 50, locationListener);
}
}
}
}
private void updateWithNewLocation(Location location) {
if (location != null) {
Log.v("location", "===>location ed " + lat);
lat = location.getLatitude();
lng = location.getLongitude();
}
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}
Hello I have implemented a service that broadcasts the current location. the thing is the first time it updates it gives me 0.0 lat and 0.0 lon, which ruins the UI.how can I fix this?
Here is the code, thank you
public class LocationService extends Service {
protected LocationManager locationManager;
final static String MY_ACTION = "MY_ACTION";
MyLocListener myloc = new MyLocListener();
#Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
#Override public void onDestroy() {
};
#Override
public int onStartCommand(Intent intent, int flags, int startId){
final Criteria criteria = new Criteria();
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(true);
criteria.setSpeedRequired(false);
criteria.setCostAllowed(true);
LocationListener ll = new MyLocListener();
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 100, 0, ll);
Location location = new Location("abc");
ll.onLocationChanged(location);
Log.d("Last", ""+location.getLatitude());
return START_STICKY;
}
private class MyLocListener implements LocationListener {
public void onLocationChanged(Location location) {
Log.d("1provider",location.toString());
Log.d("1Provider LOCATION CHANGED", location.getLatitude() + "");
Log.d("1Provider LOCATION CHANGED", location.getLongitude() + "");
Intent intent = new Intent();
intent.putExtra("location", location);
intent.setAction(MY_ACTION);
sendBroadcast(intent);
}
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
Log.d("1Provider DIsabled", "Provider Disabled");
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
Log.d("1Provider Enabled", "Provider Enabled");
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
Log.d("1Provider Changed", "Service Status Changed");
}
}
}
The onLocationChanged() method usually returns 0 on the first occasion - just check for this value and don't update the UI. As to it taking too long, it can take a while so run your service as an AsyncTask when getting the location, so that your UI thread is waiting around, and then update the UI when you get a return from the AsyncTask.
I am new user to Stackoverflow and this is my first question...
Question is...
How to get the periodic updates of location details? I have tried with Service class and run thread inside it but,This is called only once.
Can any one suggest me what I am doing wrong? Thank you.
Here is my code
public class MyService extends Service
{
String GPS_FILTER = "";
Thread triggerService;
LocationManager lm;
GpsListener gpsLocationListener;
boolean isRunning = true;
#Override
public void onCreate()
{
// TODO Auto-generated method stub
super.onCreate();
Toast.makeText(getApplicationContext(), "Hello",Toast.LENGTH_LONG).show();
GPS_FILTER = "MyGPSLocation";
}
#Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
triggerService = new Thread(new Runnable(){
public void run(){
try{
Looper.prepare();//Initialize the current thread as a looper.
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Toast.makeText(getApplicationContext(), "Hello1",Toast.LENGTH_LONG).show();
gpsLocationListener = new GpsListener();
long minTime = 30000; // 5 sec...
float minDistance = 10;
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime,
minDistance, gpsLocationListener);
Looper.loop();
}catch(Exception ex){
System.out.println("Exception in triggerService Thread -- "+ex);
}
}
}, "myLocationThread");
triggerService.start();
}
#Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
removeGpsListener();
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
private void removeGpsListener(){
try{
lm.removeUpdates(gpsLocationListener);
}
catch(Exception ex){
System.out.println("Exception in GPSService --- "+ex);
}
}
class GpsListener implements LocationListener{
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
double latitude = location.getLatitude();
double longitude = location.getLongitude();
sendBroadcast(filterRes);
postdata();
}**
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
}
My updated answer
This Call to service class
Calendar cur_cal = Calendar.getInstance();
cur_cal.setTimeInMillis(System.currentTimeMillis());
Intent intent = new Intent(this, MyService.class);
PendingIntent pintent = PendingIntent.getService(login.this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
public class MyService extends Service
{
String GPS_FILTER = "";
Thread triggerService;
LocationListener locationListener;
LocationManager lm;
private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1000; // in Meters
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000*60; // in Milliseconds
protected LocationManager locationManager;
boolean isRunning = true;
#Override
public void onCreate()
{
// TODO Auto-generated method stub
super.onCreate();
GPS_FILTER = "MyGPSLocation";
// locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// locationManager.requestLocationUpdates(
// LocationManager.GPS_PROVIDER,
// MINIMUM_TIME_BETWEEN_UPDATES,
// MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
// new MyLocationListener());
}
#Override
public void onStart(Intent intent, int startId)
{
// TODO Auto-generated method stub
super.onStart(intent, startId);
turnGPSOn();
Toast.makeText(getApplicationContext(), "Hello1",Toast.LENGTH_LONG).show();
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationListener = new MyLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MINIMUM_TIME_BETWEEN_UPDATES, 1.0f, locationListener);
}
#Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
// removeGpsListener();
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
// private void removeGpsListener(){
// try{
// lm.removeUpdates(locationManager);
// }
// catch(Exception ex){
// System.out.println("Exception in GPSService --- "+ex);
// }
// }
private class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location location)
{
postdata(location.getLatitude(),location.getLongitude());
String message = String.format(
"New Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude()
);
Toast.makeText(MyService.this, message, Toast.LENGTH_LONG).show();
turnGPSOnOff();
}
public void onStatusChanged(String s, int i, Bundle b) {
// Toast.makeText(MyService.this, "Provider status changed",
// Toast.LENGTH_LONG).show();
}
public void onProviderDisabled(String s) {
// Toast.makeText(MyService.this,
// "Provider disabled by the user. GPS turned off",
// Toast.LENGTH_LONG).show();
}
public void onProviderEnabled(String s) {
// Toast.makeText(MyService.this,
// "Provider enabled by the user. GPS turned on",
// Toast.LENGTH_LONG).show();
}
}
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cur_cal.getTimeInMillis(), 60*1000, pintent);
Try Puuting things that you want to do inside run of this class,
This thread runs every 5 Seconds,
You can modify it as you want.
public class PeriodicChecker extends Thread
{
#Override
public void run()
{
while(true) {
System.out.println("Thread is doing something");
//Put Your code here
Thread.sleep(5000);
}
}
}
public OtherClass {
public static void main(String args[]) {
Thread t = new PeriodicChecker();
t.start();
}
}
I am using service class which gives a call to my inner class that implements Location Listener which provides me my location details... but I need to do this in regular interval.. I have used Thread with looper but it executes only once Please help
This is my udated answer
Updated answer
public class MyService extends Service
{
String GPS_FILTER = "";
Thread triggerService;
LocationListener locationListener;
LocationManager lm;
private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1000; // in Meters
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000*60; // in Milliseconds
protected LocationManager locationManager;
boolean isRunning = true;
#Override
public void onCreate()
{
// TODO Auto-generated method stub
super.onCreate();
GPS_FILTER = "MyGPSLocation";
// locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// locationManager.requestLocationUpdates(
// LocationManager.GPS_PROVIDER,
// MINIMUM_TIME_BETWEEN_UPDATES,
// MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
// new MyLocationListener());
}
#Override
public void onStart(Intent intent, int startId)
{
// TODO Auto-generated method stub
super.onStart(intent, startId);
turnGPSOn();
Toast.makeText(getApplicationContext(), "Hello1",Toast.LENGTH_LONG).show();
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationListener = new MyLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MINIMUM_TIME_BETWEEN_UPDATES, 1.0f, locationListener);
}
#Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
// removeGpsListener();
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
// private void removeGpsListener(){
// try{
// lm.removeUpdates(locationManager);
// }
// catch(Exception ex){
// System.out.println("Exception in GPSService --- "+ex);
// }
// }
private class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location location)
{
postdata(location.getLatitude(),location.getLongitude());
String message = String.format(
"New Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude()
);
Toast.makeText(MyService.this, message, Toast.LENGTH_LONG).show();
turnGPSOnOff();
}
public void onStatusChanged(String s, int i, Bundle b) {
// Toast.makeText(MyService.this, "Provider status changed",
// Toast.LENGTH_LONG).show();
}
public void onProviderDisabled(String s) {
// Toast.makeText(MyService.this,
// "Provider disabled by the user. GPS turned off",
// Toast.LENGTH_LONG).show();
}
public void onProviderEnabled(String s) {
// Toast.makeText(MyService.this,
// "Provider enabled by the user. GPS turned on",
// Toast.LENGTH_LONG).show();
}
}
also call service using
Calendar cur_cal = Calendar.getInstance();
cur_cal.setTimeInMillis(System.currentTimeMillis());
Intent intent = new Intent(this, MyService.class);
PendingIntent pintent = PendingIntent.getService(login.this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cur_cal.getTimeInMillis(), 60*1000, pintent);
try this...
TimerTask doAsynchronousTask;
long timerCall = 5000;
final Handler handler = new Handler();
Timer timer = new Timer();
public static int times = 0;
// For tracking
doAsynchronousTask = new TimerTask() {
#Override
public void run() {
handler.post(new Runnable() {
public void run() {
try {
performBackgroundTask.execute();//In this function add your code which you want to call repeatedly. OR ADD lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Toast.makeText(getApplicationContext(), "Hello1",Toast.LENGTH_LONG).show();
gpsLocationListener = new GpsListener();
long minTime = 30000; // 5 sec...
float minDistance = 10;
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, minDistance, gpsLocationListener);
Log.d("BGT", "BGT=" + times++);//how many time it called
} catch (Exception e) {
}
}
});
}
};
timer.schedule(doAsynchronousTask, 0, timerCall);// execute in every 50000 ms
`