0

I am trying to open a website with chrome app from my android app. 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:

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

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

Pardon me if the question i asked is duplicated.

1 Answers1

-1

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

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?

Hope this helps a bit!

Bree
  • 46
  • 6
  • Hi, and thx for the reply but i think this tutorial (https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#6 ) is about responding to the intent. Although it is relevant but it does not answer my question. However, i found that the chrome app refused to launch when i run and click the button to launch it from my android app in emulator, while it launched the chrome app if the android app is run on a phone. I guess i have a little bit of clue now. Again, thanks for the reply and advice. – Goh Ying Teik Aug 08 '20 at 05:17