i've been trying send location via share intent through whatsapp, code far:
string uri = "geo:" + currentloc.getlatitude() + "," +currentloc.getlongitude() + "?q=" + currentloc.getlatitude() + "," + currentloc.getlongitude(); intent i=new intent(android.content.intent.action_view, uri.parse(uri)); startactivity(i);
the problem when app chooser opens shows "google maps" , "waze". how can modify can send many other apps support location whatsapp or facebook?
try use code below, example official documentation.
intent sendintent = new intent(); sendintent.setaction(intent.action_send); sendintent.putextra(intent.extra_text, "this location send."); sendintent.settype("text/plain"); startactivity(sendintent); public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.share, menu); menuitem item = menu.finditem(r.id.share_item); actionprovider = (shareactionprovider) item.getactionprovider(); // create share intent string sharetext = url_to_share; intent shareintent = sharecompat.intentbuilder.from(this) .settype("text/plain").settext(sharetext).getintent(); actionprovider.setshareintent(shareintent); return true; }
another option can directly specify app open intent adding package name intent.
sendintent.setpackage("com.whatsapp"); startactivity(sendintent);