0

i want to share the Location on click the pin on mapv2. i already implement the popup on press pin but the not idea about the location share. so any one can implement in it..

     ButtonListener = new PopupWindowTouchListener(popupButton) {
        @Override
        protected void onClickConfirmed(View v, Marker marker) {
    //              Toast.makeText(MainActivity.this, "button1 clicked!", Toast.LENGTH_SHORT).show();

            String message = "http://maps.google.com/maps?q=" + latitude + "," + longitude + "&iwloc=A";
            System.out.println("message...> " + message);
            sendSMS("**********",message);

        }
    }; 


   private void sendSMS(String phoneNumber, String message){

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

} 

2 Answers2

1

Marker.getPosition() will return LatLng

LatLng latlng = Marker.getPosition();
Double latitude = latlng.latitude;
Double longitude = latlng.longitude;

You can manipulate the latitude and longitude values to construct your data format. And use Intent chooser to share.

For example "http://maps.google.com/maps?q=" + latitude + "," + longitude + "&iwloc=A" and share it via SMS

Vinothkumar Arputharaj
  • 4,567
  • 4
  • 29
  • 36
  • Hello when we use this functionality with share intent in that when we share location in wattsup application that time one google default add can bi attached you have any idea to remove this @Vinothkumar Arputharaj – Ricky Patel Apr 28 '16 at 08:40
0
    String uri = "http://maps.google.com/maps?saddr=" +latitude+","+longitude;
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    String ShareSub = "Here is my location";
    sharingIntent.putExtra(Intent.EXTRA_SUBJECT, ShareSub);
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, uri );
    startActivity(Intent.createChooser(sharingIntent, "Share via"));