【发布时间】:2020-08-07 18:07:58
【问题描述】:
我正在尝试从我的 android 应用中打开一个带有 chrome 应用的网站。但是,每次单击链接到以下代码的按钮时,我都没有得到任何响应:
public void openWebsite(View view) {
//Get the url text
String url = mWebsiteEditText.getText().toString();
//Parse the URI and create the intent
Uri webpage = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
//Find an activity to hand the intent and start that activity.
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}else{
Log.d("ImplicitIntents","Cant handle this");
}
}
我从这里https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#3 学习并遵循代码,下面是我在单击按钮打开链接时在 android studio 的 Logcat 中注意到的一些消息:
2020-08-08 01:21:23.651 767-2753/system_process I/AppsFilter: 交互:PackageSetting{cc102 com.example.implicitintents/10160} -> PackageSetting{bbc8e62 com.android.chrome/10129} 阻塞
2020-08-08 01:21:23.652 31691-31691/com.example.implicitintents D/ImplicitIntents:无法处理
应用应该打开 chrome,如下所示:https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#5
如果我问的问题是重复的,请原谅我。
【问题讨论】:
-
嗨,你找到背后的原因了吗?
标签: java android android-studio android-intent android-activity