I don't want to use service which is continuously running in background ! Actually in my project user will send SMS command from any smartphone to his/her misplaced smartphone.My app will detect that particular "SMS command" and in return it will send the current location of misplaced mobile. can it be done through intent service ? I m damn confused ... Its single time operation how to perform it efficiently ... ?
Asked
Active
Viewed 394 times
0
-
use GPS service – Venki WAR May 30 '18 at 11:22
-
1can you provide any link or code ? – Qaiser Hussain May 30 '18 at 11:24
-
can you please be more descriptive with adding code – Learning Always May 30 '18 at 11:26
-
1Possible duplicate of [How do I get the current GPS location programmatically in Android?](https://stackoverflow.com/questions/1513485/how-do-i-get-the-current-gps-location-programmatically-in-android) – Ganesh K May 30 '18 at 11:28
-
or use NETWORK_PROVIDER – Venki WAR May 30 '18 at 11:28
-
bro I told you I have no idea how to start but I am sure it should be done via background service ! its single time operation therefore probably intent service should be used ... – Qaiser Hussain May 30 '18 at 11:30
-
yaa i read your question.In android we can get location 3 ways GPS,Internet and mobile Network provider – Venki WAR May 30 '18 at 11:39
1 Answers
0
by using NETWORK_PROVIDER
getting geolocation
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
and add this permission in manifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Venki WAR
- 1,997
- 4
- 25
- 38
-
should I copy this code in intent service then call this intent service in broadcast receiver ? – Qaiser Hussain May 30 '18 at 11:38
-
I think your app must run in background for finding SMS Command .If command found you simply send geolocation that number – Venki WAR May 30 '18 at 11:43
-
I have done that job "finding SMS Command" I have used incoming SMS broadcast receiver for it blah blah ... do I just need to call ur code from broadcast receiver that's it ? – Qaiser Hussain May 30 '18 at 11:49