Intention: URI not working in Android browser

So, I click on this link:

<a href="intent://www.google.com#Intent;scheme=http;action=android.intent.action.VIEW;end">Google</a> 

(I know his stupid example, as it may be http://www.google.com , but its illustration of the problem)

I defined this URI from

 Log.v(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://www.google.com")).toUri( Intent.URI_INTENT_SCHEME)); 

In logcat, I see the following:

 08-02 08:32:34.708 I/ActivityManager( 71): Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://www.google.com cmp=com.android.browser/.BrowserActivity } 08-02 08:32:34.748 E/Tab ( 4188): onReceivedError -10 intent://www.google.com#Intent;scheme=http;action=android.intent.action.VIEW;end The protocol is not supported 

Instead of redirecting to www.google.com, I get the "Webpage Unavailable" page.

If I run identical intentions using the binary am , it succeeds.

 adb -e shell am start -d http://www.google.com -a android.intent.action.VIEW 

I see this in logcat

 08-02 08:47:42.488 I/ActivityManager( 71): Starting activity: Intent { act=android.intent.action.VIEW dat=http://www.google.com flg=0x10000000 cmp=com.android.browser/.BrowserActivity } 

The ultimate goal is to have a URL that triggers a certain activity in the application (and cannot someone get to this page without installing the application). I know that I can also define a custom schema, but since this is a global namespace, I would not do that. I also know that for this purpose I can use http: //, but I do not want the user to be prompted to open the URL in a browser or my application.

Any ideas?

+4
source share
1 answer

I faced the same problem

Adding the following code to my activity in AndroidManifest.xml solved my problem:

 <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> 
+6
source

Source: https://habr.com/ru/post/1379926/


All Articles