Custom deeplinking scheme doesn't work in some cases - android

Custom deeplinking scheme doesn't work in case other data tag is added to 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="#string/deep_link_scheme" />
<data android:scheme="http" android:host="myhost" />
<data android:scheme="https" android:host="myhost" />
</intent-filter>
Moving custom theme data tag to separate intent-filter fixes the problem, but what the real problem with the first solution?
<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="myhost" />
<data android:scheme="https" android:host="myhost" />
</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="#string/deep_link_scheme" />
</intent-filter>

Related

Intent filter for dynamic links is not working as expected

I have following intent filter set up for detecting links to open in our app.
<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="share.example.tv"
android:pathPrefix="/"
android:scheme="https" />
<data
android:host="example.tv"
android:pathPrefix="/u"
android:scheme="https" />
</intent-filter>
I want my app to open below 2 links
https://share.example.tv/tv34gh
https://example.tv/u/some-user-name
But my app is showing up for these links as well
https://example.tv/anything/literally-anything
If I separate both of the links in different intent-filters for same activity like below
<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="share.example.tv"
android:pathPrefix="/"
android:scheme="https" />
</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:host="example.tv"
android:pathPrefix="/u"
android:scheme="https" />
</intent-filter>
This works but I don't know why.

How to show my app as a downloader

How can i register my app as a downloader as shown in the screenshot below. I have tried adding below code in my manifest but didn't work.
<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" />
</intent-filter>
here is my activity in manifest:
<activity
android:name=".modules.downloader.home.HomeActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</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>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
You need to provide MIME type as well. If you support all types of files, then you can give <data android:mimeType="*/*" />
<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:mimeType="*/*" android:scheme="http" />
<data android:mimeType="*/*" android:scheme="https" />
</intent-filter>

Appear my media player when any video is played from gallery or file explorer

I am using the following code in manifest but it is not working.
<activity
android:name=".Videoplay"
android:configChanges="orientation|keyboardHidden|screenLayout|screenSize"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.APP_MUSIC" />
<!-- <data android:mimeType="*/*"></data> -->
<data android:mimeType="audio/mpeg" />
<data android:mimeType="video/mpeg" />
<data android:pathPattern=".*\.mp3" />
<data android:pathPattern=".*\.ogg" />
<data android:pathPattern=".*\.wav" />
<data android:pathPattern=".*\.wma" />
<data android:pathPattern=".*\.flac"/>
<data android:pathPattern=".*\.mp4"/>
<data android:pathPattern=".*\.mkv" />
</intent-filter>
</activity>
Help me, what's going wrong because my app is not showing in the video intent.
Use the below 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="rtsp" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
<data android:mimeType="application/sdp" />
</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="http" />
<data android:mimeType="video/*" />
</intent-filter>

Android intent-filter path pattern

I want to make intent-filter which can detect urls like this one:
http://www.example.com/?p=12345
I tried with this code:
<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="www.example.com"
android:pathPattern="/\\?p=.*"/>
</intent-filter>
But it doesn't work. Can anybody help?
I found answer
<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="www.example.com"
android:pathPattern="/*"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPattern="/.*/"
android:scheme="http" />
</intent-filter>

Correct Android intent-filter configuration to associate a file type with an Activity?

This question has been asked [numerous times] before, but I have not seen any definitive answers, or examples of code that actually works.
I would like to associate an Activity with a particular file type.
For discussion, assume that I want my Activity to be associated with PDFs.
Here is what I currently have. I have experimented with many different values and combinations of values in the intent-filter, but I have yet to get my Activity to start when a PDF is selected.
<activity name="com.mycompany.MyActivity">
<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="file" />
<data android:mimeType="application/pdf" />
<data android:pathPattern="\\*\\.pdf" />
<data android:host="*" />
</intent-filter>
</activity>
Does anyone know how to actually make this work?
Have you tried with that simple version :
<activity name="com.mycompany.MyActivity">
<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:mimeType="application/pdf" />
</intent-filter>
</activity>
Your pathPattern is definitively wrong and you are restricting it too much with the mimetype.
Try the following:
<activity name="com.mycompany.MyActivity">
<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:host="*" />
<data android:pathPattern=".*\\.pdf" />
</intent-filter>
<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:host="*" />
<data android:mimeType="application/pdf" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.pdf" />
</intent-filter>
</activity>
To open both local and remote pdf files I'd do:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.pdf" />
</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="http" android:host="*" android:pathPattern=".*\\.pdf" />
<data android:scheme="https" android:host="*" android:pathPattern=".*\\.pdf" />
</intent-filter>

Categories

Resources