简体   繁体   English

尝试使用来自另一个 android 应用程序的 URL 链接打开 chrome 应用程序

[英]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.

相关问题 尝试打开告诉链接时,Android Webview应用程序崩溃 - Android webview app crash when trying to open tell link 从另一个应用程序接收共享 URL 到我的 Android 应用程序无法正常工作 - Receiving a shared URL from another app into my Android app not working 如何从Android应用程序中隐藏Google Chrome中的网页 - How to open a web page in Google chrome incognito from android app Socrata URL可在Chrome浏览器中使用,而不能在Android应用程序中使用 - Socrata URL works from Chrome, not from Android app 如何从Android应用程序打开“保存到Android Pay” URL? - How to open “save to android pay” url from android app? 从链接启动Android应用程序,并导航到特定的URL? - Launching Android app from a link, and navigating to a particular URL? (Android应用)尝试将AlertDialog .setIcon()设置为从URL下载的图像 - (Android App) Trying to set AlertDialog .setIcon() as an image downloaded from URL 允许用户将链接从应用发送给其他人,然后在单击时打开应用 - Allow user to send link from app to another person and then open app when clicked 如何在 Android 应用程序中打开具有多个选项的链接 - How to open a link with multiple choices in an Android app 如果存在的话,打开pinterest链接与pinterest应用程序 - android - open pinterest link with pinterest app if exist - android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM