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

javascript - Trigger mouseenter when an animated element touches mouse -

json - Zend error Connection -

java - Using Spring @Transactional with a combination of readOnly and write, when does this entity get committed? -