1

I have developed an application that shows one's location on a map. How do I go about sharing my current location with others who are using my application? Is it possible to send them a notification to let them know my current location?

bobo
  • 185
  • 1
  • 4
  • 9
  • 1
    yes, but did you search on the ways of sending notification to other mobile numbers??? – Farhan Apr 30 '11 at 13:49
  • Thanks for the idea. So the notification will be limited to my phone book contacts – bobo Apr 30 '11 at 13:56
  • 1
    i m saying, that how will you send a notification to any number? did you think of any? well i can think of one and that is "sms"..... – Farhan Apr 30 '11 at 16:10

1 Answers1

4

A format that I use to send a location is to leverage the maps.google.com site, like:

"http://maps.google.com/maps?q=" + loc_x + "," + loc_y + "&iwloc=A"

This String can be inserted into a SMS or Email message. I found this site with some good info for formating a URL to automatically open a map centered on the given coordinates. A possible implementation for SMS could be:

String message = 
             "http://maps.google.com/maps?q=" + loc_x + "," + loc_y + "&iwloc=A";

private void sendSMS(String phoneNumber, String message){

    SmsManager sms = SmsManager.getDefault();
    Log.d(TAG, "Attempting to send an SMS to: " + phoneNumber);
    try {
        sms.sendTextMessage(phoneNumber, null, message, null, null);
    } catch (Exception e) {
        Log.e(TAG, "Error sending an SMS to: " + phoneNumber + " :: " + e);
    }       

}  

Where loc_x and loc_y represent lat and lon from a LocationManager instance.

Kingsolmn
  • 1,868
  • 2
  • 23
  • 39
  • @Android_Virus can you be a bit more specific when you say "not working", are you referring to the URL string or the code snippet? Might be able to help if you provide as much detail as you can. – Kingsolmn Feb 26 '14 at 17:11