Android packageManager.QueryInputActivities:检查已解析的应用程序是否为浏览器
在Android上,我使用Android packageManager.QueryInputActivities:检查已解析的应用程序是否为浏览器,android,Android,在Android上,我使用packageManager.queryIntentActivities返回可以处理URL的应用程序列表 我只想在专门针对该URL的应用程序中打开URL,即用于Twitter URL的Twitter应用程序,但我不想使用像Chrome或Firefox这样的通用浏览器打开URL 有没有办法检查返回的应用程序是否专门针对该URL,或者它是否是通用浏览器?中的示例 关键在于URI方案 Intent intent = null; try { // get the Twi
packageManager.queryIntentActivities
返回可以处理URL的应用程序列表
我只想在专门针对该URL的应用程序中打开URL,即用于Twitter URL的Twitter
应用程序,但我不想使用像Chrome
或Firefox
这样的通用浏览器打开URL
有没有办法检查返回的应用程序是否专门针对该URL,或者它是否是通用浏览器?中的示例
关键在于URI方案
Intent intent = null;
try {
// get the Twitter app if possible
this.getPackageManager().getPackageInfo("com.twitter.android", 0);
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id=USERID"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} catch (Exception e) {
// no Twitter app, revert to browser
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/USERID_OR_PROFILENAME"));
}
this.startActivity(intent);
添加您的意图详情hanks,但twitter只是一个例子,url可以是任何内容。