landon ashes landon ashes - 1 year ago 76
Android Question

android sms application to reveal sender's location

i am an android newbi. i extend my apologies for a very primitive question.
i intend to develop an android application for sms messaging so that when the reciever recieves a message, the sender's physical location is also automatically revealed (using the GPS of sender) may be in Lat Long format.
My question is, how to go by this problem?
bundles of thanks in advance.

Answer Source

I think.. getting the location of the sender completely depends on the sender..i.e if the sender decides to reveal his location.. only the recipient can get his location.. so.. the application you are trying to make should be in senders phone... and in this case..

create an activity with text field and a button to send the message like this..

  class A extends Activity
    String s;
 editText = (EditText) findViewById(;
 sendBtn  =  (Button)findViewById(;

sendBtn  .setonclickListener(new OnClickListener(){
public void Onclick(){
       locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        new MyLocationListener()
    Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

if (location != null) {

PendingIntent pi = PendingIntent.getActivity(this, 0,
        new Intent(this, Object.class), 0);  
     SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, s, pi, null);