Android: Service To Get And Send Gps Co-ordinates To Server
I know this is duplicate question, but I am not getting the explanatory example or solution. I want to develop an application which after run calls a background service which takes
Solution 1:
you can able to send current location or lat and lag point into your server using webservice
frequently you want to update your location or lat and lag use handler
finalHandlerhandler=newHandler();
handler.postDelayed( newRunnable() {
@Overridepublicvoidrun() {
handler.postDelayed( this, 60 * 1000 );
}
}, 60 * 1000 );
Solution 2:
You can get the Location Tracking Code Here,
you need to run service with Timers or PendingIntents.
Timertimer=newTimer();
TimerTasktask=newTimerTask() {
@Overridepublicvoidrun() {
// getLocation From Here
}
};
timer.scheduleAtFixedRate(task, 0, 60*1000);
Or
PendingIntentpendingIntent= PendingIntent.getBroadcast(mActivity,0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManageralarmManager= (AlarmManager)getSystemService(ALARM_SERVICE);
Calendarcalendar= Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 10);
interval = 1 * 60 * 1000;
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(), interval, pendingIntent);
And you can get the Location Tracking with Service Code Here
In this case you running a background service continuously. so battery will dry.
Post a Comment for "Android: Service To Get And Send Gps Co-ordinates To Server"