I am beginner at android. I have a question. I want to when I receive SMS then get my location(latitude and longitude). How can I do. if you have sample code, it will be more helpful.
Thanks for your help.
I am beginner at android. I have a question. I want to when I receive SMS then get my location(latitude and longitude). How can I do. if you have sample code, it will be more helpful.
Thanks for your help.
please refer this example. I hope it helps you.
In this example the current location will be display and touched location will also display with lat-lon.
For getting latitude and longitude when you have recived an sms on device you will need these steps:
STEP 1:
Register an android.provider.Telephony.SMS_RECEIVED
BroadcastReceiver for receiving incoming sms notification:
for this you can use following Tutorial :
http://androidsourcecode.blogspot.in/2010/10/receiving-sms-using-broadcastreceiver.html
for retrieving location on sms received you will need to start an service (IntentService
) in onReceive of SMS BroadcastReceiver as:
public class SmsReciever extends BroadcastReceiver {
private static final String TAG = "Message recieved";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
// Start your Location IntentService here
Intent i = new Intent(context, Location_Intent_Service.class);
context.startService(i);
}
}
}
http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/
For how we Use LocationManager from Service class you can follow these Post:
Starting LocationManager as Service Android