I am trying to share a location with latitude and longitude as;
String uri = "http://maps.google.com/maps?daddr=" + latLngMaps.latitude + "," + latLngMaps.longitude;
Using these lines of code:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String ShareSub = pharmacyName + "\n" + pharmacyAddress;
sharingIntent.putExtra(Intent.EXTRA_TEXT, ShareSub + "\n" + shortURL);
startActivity(Intent.createChooser(sharingIntent, "Share With?"));
What I want to do is:
I am using URL shortener api and converting the "http://maps.google.com/maps?daddr=" + latLngMaps.latitude + "," + latLngMaps.longitude;
to goo.gl/xxxxx
Is it possible to get that first Image's view when I share my map on Whatsapp?
If it is not, How can I shorten my link as goo.gl/maps/xxxx not goo.gl/xxxx ?
You need to use Google static Maps API which returns a map as an Image which you can share through intent.You can also customize static maps API like you can set marker location, set zoom level.
Url
https://maps.googleapis.com/maps/api/staticmap?center=Australia&size=640x400&style=element:labels|visibility:off&style=element:geometry.stroke|visibility:off&style=feature:landscape|element:geometry|saturation:-100&style=feature:water|saturation:-100|invert_lightness:true&key=YOUR_API_KEY
You can also use the lighter version of google map using google map options. it is also displayed as an Image. which can be clicked and also has google map customization.
visit my website for learnning Kotlin and Android - Developine
来源:https://stackoverflow.com/questions/47522022/android-sharing-intent-with-google-maps-location-and-url-shortener-api