[英]Trying to open chrome app with a URL link from another android app
I am trying to open a website with chrome app from my android app.我正在尝试从我的 android 应用程序中打开一个带有 chrome 应用程序的网站。 However, i am not getting any response each time i click the button which link to the code below:
但是,每次单击链接到以下代码的按钮时,我都没有得到任何响应:
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");
}
}
i learned and follow the code from here https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#3 and below is some of the message i noticed in the Logcat in android studio when i click the button to open the link:我从这里学习并遵循代码https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training# 3及以下是我在 android 工作室的 Logcat 中注意到的一些消息,当我单击按钮打开链接时:
2020-08-08 01:21:23.651 767-2753/system_process I/AppsFilter: interaction: PackageSetting{cc102 com.example.implicitintents/10160} -> PackageSetting{bbc8e62 com.android.chrome/10129} BLOCKED 2020-08-08 01:21:23.651 767-2753/system_process I/AppsFilter: interaction: PackageSetting{cc102 com.example.implicitintents/10160} -> PackageSetting{bbc8e62 com.android.chrome/10129} BLOCKED
2020-08-08 01:21:23.652 31691-31691/com.example.implicitintents D/ImplicitIntents: Cant handle this 2020-08-08 01:21:23.652 31691-31691/com.example.implicitintents D/ImplicitIntents:无法处理
The app should open chrome just as shown here: https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#5该应用程序应该打开 chrome,如下所示: https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-培训#5
Pardon me if the question i asked is duplicated.如果我问的问题是重复的,请原谅我。
I think you might be missing some things in your manifest file.我认为您可能在清单文件中遗漏了一些东西。 Did you follow this part of the tutorial?
您是否按照教程的这一部分进行操作? What does yours look like?
你的是什么样子的?
https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#6 https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#6
in particular this part:特别是这部分:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="developer.android.com" />
</intent-filter>
also I think you will need the internet permission to access websites so I would add this too:我也认为你需要互联网许可才能访问网站,所以我也会添加这个:
<uses-permission android:name="android.permission.INTERNET" />
What permission do I need to access Internet from an Android application? 从 Android 应用程序访问 Internet 需要什么权限?
Hope this helps a bit!希望这个对你有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.