Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share location like whatsapp?

I wanna share some fixed lat,long & text via ACTION_SEND using Intent. I can share url like String shareBody = "http://maps.google.com?q="+lat+","+lng; & Image like

sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://" + context.getPackageName()
                        + "/drawable/" + "ic_launcher"));
sharingIntent.setType("image/*")

but i cant find the way which whatsapp using to share location. Is there any way to share location like whatsapp did? OR pass some static image & by clicking on that image, map should be open in default chooser @ user side.Is there any way to implement that scenario?

Thanks.

like image 713
Bhoomika Brahmbhatt Avatar asked Nov 10 '22 12:11

Bhoomika Brahmbhatt


1 Answers

there's an really awesome github project called yowsup who reverse engineered whatsapp protocol. here's the location sharing layer from it, you might find it handy

<message t="{{TIME_STAMP}}" from="{{CONTACT_JID}}" 
    offline="{{OFFLINE}}" type="text" id="{{MESSAGE_ID}}" notify="{{NOTIFY_NAME}}">
        <media 
            latitude="52.52393" 
            type="location"
            longitude="13.41747"
            name="Location Name"
            url="http://www.foursquare.com/XXXX"
            encoding="raw"
        >{{THUMBNAIL_RAWDATA}}</media>
    </message>
like image 143
akiva Avatar answered Nov 14 '22 21:11

akiva