-1

I have a question related to the gps system in android.

I want to have the following functionality in my android app:

-Once the application is installed on the android device then it is always running in the background.

-I have a gps enabled android device then if I am 300-400 meters away from a particular address(Where address means we have provided the address to the application for finding location) then a popup appears on the screen stating I am x meters away from the target. (I would want this popup to occur every time I am 100m closer)

I have tried looking on Google for the correct way to do this but I have been unsuccessful and any help would be appreciated.

My main problems are:

1)Always having my program running in the background.

2)Have a popup to notify the user.

3)How to calculate my distance from a particular location.

1 Answers1

1

You can get the distance in meter by

Location location;
float distance[];
location.distanceBetween(From Latitude, From Longitude, TO Latitude, TO Longitude,
                        distance);

When you user goes 300 meter , you can popup the screen in home activity (Use background service to do that)

Once app installed stat the service. Remember that user can kill the service

Community
  • 1
  • 1
AnanThDev
  • 337
  • 2
  • 16
  • where i put the distance 300 meter in the program. and how can i start the service for particular my app. means what code i wright for that. @AnanThDev – Hemant.ACS Mar 28 '14 at 13:26
  • Please anyone give me some coding example about how i create service in background about above query. Please give me solution i really appreciate that person who helping me. – Hemant.ACS Apr 02 '14 at 08:09
  • Link 1:- http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/ Link 2:-http://code.google.com/p/krvarma-android-samples/source/browse/#svn%2Ftrunk%2FGPSLogger – AnanThDev Apr 02 '14 at 10:25
  • first link you provided i already applied but not getting success because my problem is different. Second link you provided if i run the project then in the logcat it shows like that:- Service Started with interval 5, Logfile name: GPSLog.2014-04-04 05:03:37.kml. But what does this application do i don't understand, and also nothing file is shown in the DDMS under /sdcard. please help me for this issue. – Hemant.ACS Apr 04 '14 at 09:18