I have to activities that i need to deep-link them to two URLS, but every time i click a URL it shows the two activities at the same time, so How can i set the intent-filter to only 1 specific URL ?
1st URL http://www.sample.com/newcars/models/33
and its activity
<activity
android:name=".ui.activities.NewCarModelEngineActivity"
android:label="#string/newCars"
android:screenOrientation="sensorPortrait">
<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:host="sample.com"
android:pathPrefix="/newcars/engines/"
android:scheme="http"/>
<data
android:host="www.sample.com"
android:pathPrefix="/newcars/engines/"
android:scheme="http"/>
<data
android:host="newengine"
android:pathPattern="/..*/..*/..*"
android:scheme="sample"></data>
</intent-filter>
</activity>
2nd URL http://www.sample.com/usedcars/engines/9876543
and its activity
<activity
android:name=".ui.activities.UsedCarEngineDetailsActivity"
android:label="#string/usedCars"
android:screenOrientation="sensorPortrait">
<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:host="sample.com"
android:pathPrefix="/usedcars/engines/"
android:scheme="http"/>
<data
android:host="www.sample.com"
android:pathPrefix="/usedcars/engines/"
android:scheme="http"/>
<data
android:host="usedengine"
android:pathPattern="/..*/..*/..*"
android:scheme="sample"></data>
</intent-filter>
</activity>
Try to put your scheme="sample" data in a separate intent filter. It seems like a bug, but sometimes Android just ignores the path prefix when another is present and empty or with wildcards.
You can also use host="*sample.com" to match both sample.com and www.sample.com.
Ex for your first activity:
<activity
android:name=".ui.activities.NewCarModelEngineActivity"
android:label="#string/newCars"
android:screenOrientation="sensorPortrait">
<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="*sample.com"
android:pathPrefix="/newcars/engines/" />
</intent-filter>
<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="sample"
android:host="newengine"
android:pathPattern="/..*/..*/..*" />
</intent-filter>
</activity>
Related
Hi I'm trying to include the app-links as described here:
https://developer.android.com/training/app-links
Everything works fine with a single domain, but when I try to include multiple domains Android's system always shows the disambiguation dialog.
Is there any workaround to include multiple domains (not SUBdomains), in my manifest file avoiding to show disambiguation dialog?
Here my AndroidManifest.xml
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleInstance" android:name="MainActivity" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="exampl1.it" android:scheme="http" android:path="/applink"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="example1.it" android:scheme="https" android:path="/applink"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="p.example2.it" android:scheme="http"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="p.example2.it" android:scheme="https"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="example3.com" android:scheme="http" android:path="/path/to-deep"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="example3.com" android:scheme="https" android:path="/path/to-deep"/>
</intent-filter>
</activity>
See my answer at https://stackoverflow.com/a/60342565/2914140. I divided all <data> tags into attributes:
<data android:scheme="https" />
<data android:host="example.com" />
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="audio/*"/>
<data android:mimeType="text/plain"/>
</intent-filter>
This is not working in Oreo and the same code is working perfectly till android 7.0
Try adding two different intent filters, like:
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="audio/*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
Reference: https://developer.android.com/training/sharing/receive
I want to download files from browser through my application. I am trying to list my app in complete action using dialog. It shows for other action like view files, etc but in case of download files it doesn't show in dialog. how can i list my app like in the image?
I have used these filters in my activity
<intent-filter> <action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.OPENABLE"/> <category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="*/*"/>
I have done this by adding these filters and now it's working for all cases.
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.LAUNCHER"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<category
android:name="android.intent.category.APP_BROWSER"/>
<category
android:name="android.intent.category.NOTIFICATION_PREFERENCES"/>
</intent-filter>
<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="googlechrome"/>
<data
android:scheme="http"/>
<data
android:scheme="https"/>
<data
android:scheme="about"/>
<data
android:scheme="javascript"/>
</intent-filter>
<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="googlechrome"/>
<data
android:scheme="http"/>
<data
android:scheme="https"/>
<data
android:scheme="about"/>
<data
android:scheme="content"/>
<data
android:scheme="javascript"/>
<data
android:mimeType="text/html"/>
<data
android:mimeType="text/plain"/>
<data
android:mimeType="application/xhtml+xml"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<data
android:mimeType="multipart/related"
android:scheme="file"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.MEDIA_SEARCH"/>
<category
android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action
android:name="android.speech.action.VOICE_SEARCH_RESULTS"/>
<category
android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter
android:priority="-101">
<action
android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category
android:name="android.intent.category.DEFAULT"/>
<data
android:scheme="http"/>
<data
android:scheme="https"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.SEARCH"/>
</intent-filter>
<intent-filter>
<action
android:name="com.sec.android.airview.HOVER"/>
</intent-filter>
add these two tags inside your <intent-filter> tag
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
add this code in your manifest inside your launcher activity tag.
<activity
android:name=".YourActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>
Try downloading the files using the API http://developer.android.com/reference/android/app/DownloadManager.html
I want to open my app's LoginActivity when click on a <a href="www.myhost.com"/> in some web in Chrome browser app. I have this code but it is not working:
<activity android:label="#string/app_name" android:launchMode="singleTask"
android:name=".activities.LoginActivity" android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<data android:scheme="http" android:host="myhost.com"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
What am I doing wrong?
Thanks.
You need to set it up like this :
<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:host="example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
</intent-filter>
Notice that in your case, you would need to use android:pathPrefix instead of android:path.
How can I open a browser intent and point it to a local url in Android?
am start -a android.intent.action.VIEW -d file:///data/local_page/index.html
Doesn't work. This only seems to work with http:// prefix.
Try adding the component part:
am start ... -n com.android.browser/.BrowserActivity ...
That made a local HTML file display in the browser for me, on Android 2.2 (HTC Desire) and 2.3 (Sony-Ericsson Xperia)
Try adding -t text/html
These are the filters the browser uses:
(Not sure what android:scheme="inline" is for... does anyone know?)
<activity android:name="BrowserActivity" android:label="#string/application_name" android:launchMode="singleTask" android:alwaysRetainTaskState="true" android:configChanges="orientation|keyboardHidden" android:theme="#style/BrowserTheme" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.speech.action.VOICE_SEARCH_RESULTS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<!--
For these schemes were not particular MIME type has been supplied, we are a good candidate.
-->
<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"/>
<data android:scheme="https"/>
<data android:scheme="about"/>
<data android:scheme="javascript"/>
</intent-filter>
<!--
For these schemes where any of these particular MIME types have been supplied, we are a good candidate.
-->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:scheme="inline"/>
<data android:mimeType="text/html"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="application/xhtml+xml"/>
<data android:mimeType="application/vnd.wap.xhtml+xml"/>
</intent-filter>
<!-- We are also the main entry point of the browser. -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
<!--
The maps app is a much better experience, so it's not worth having this at all... especially for a demo! <intent-filter android:label="Map In Browser"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.cursor.item/postal-address" /> </intent-filter>
-->
<intent-filter>
<action android:name="android.intent.action.WEB_SEARCH"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme=""/>
<data android:scheme="http"/>
<data android:scheme="https"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MEDIA_SEARCH"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="#xml/searchable"/>
</activity>