android - Overflow menu item redirects to facebook, twitter, instagram applications etc -


i able redirect menu items particular website via mobile's browser. want users redirect these social networking website's application if have installed in device.

these simple code facebook redirecting website in mobile's browser. please me reach application instead.

    case r.id.facebook:     string url = "https://www.facebook.com/?_rdr=p";     startactivity(new intent(intent.action_view).setdata(uri.parse(url)));     break; 

try this

public void redirect(packagename, url) {     uri uri = uri.parse(url);     intent intent = new intent(intent.action_view, uri);      try {         intent inappintent = intent;         inappintent.setpackage(packagename);         startactivity(inappintent);     } catch (activitynotfoundexception e) {         startactivity(intent);     } } 

call method like:

for facebook: redirect("com.facebook.katana", url);

for instagram: redirect("com.instagram.android", url);

for twitter: redirect("com.twitter.android", url);

facebook not working now. think changed something. please go post


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -