landon ashes landon ashes - 6 months ago 20
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

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;
Oncreate()
{
 editText = (EditText) findViewById(R.id.message);
 sendBtn  =  (Button)findViewById(R.id.send);

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

if (location != null) {

    clat=location.getLatitude();
    clon=location.getLongitude();
       }
    s=editText.getText().toString()+"lat"+clat+"long"+clong
PendingIntent pi = PendingIntent.getActivity(this, 0,
        new Intent(this, Object.class), 0);  
     SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, s, pi, null);  
}
});

 }
Comments