Discover default Twitter app and open URL with it
-
14-06-2021 - |
문제
In application we retrieve JSON object from a server that includes also URLs to verified twitter accounts or featured tweet messages. When app user click on one of these specific links we would like to launch default twitter application for device. I had look on number of questions posted here like Start twitter app or Android Intent for Twitter application but they have flows like ACTION_SEND or ACTION_VIEW on HTC Desire HD will not recognise HTC Peep as one of the application to able to open twitter link, setType method with parameter of application/twitter on number of devices didn't return any results at all. So is there way to find default twitter app or list only twitter apps available on device?
해결책 2
Not possible at the moment, so I'm gone close this
다른 팁
You can abdicate this to the user's choice. Just open a URL, the system will then ask the user which of her installed apps she wants to use. If she has already set TweetDeck as the preferred handler for twitter.com URLs, that's what will open.
String url = "https://twitter.com/edent";
Intent in = new Intent(Intent.ACTION_VIEW);
in.setData(Uri.parse(url));
startActivity(in);
That will then either open the default Twitter app, or if there isn't one, propmt the user to select one. If no Twitter app is installed, it will open the mobile web version in the default browser.