Launch application from gmail app - android

I have a android application to preview .dst file type,i am able launch the app by clicking on file from the file explorer i did it by following 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="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.DST" />
<data android:host="*" />
</intent-filter>
now i need to launch the app from the default gmail app,i think i need to change the
android:scheme="file"
tag ,please help me with the proper scheme for gmail application..

update the manifest as 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="*" />
<data android:mimeType="application/octet-stream"
/>
<data android:pathPattern=".*\\.DST" />
</intent-filter>

Related

Android Q PDF type file extension open through file manager

I'm trying to let user have the option to open pdf files through my app.
So, when a user clicks on a pdf file from the file manager they should have the option to open it with my app along with other pdf reader apps if available in their device.
I've added the following intent filters in the manifest by scouring through various answer here. They seem to work below Api 29 (my app shows in the list upon clicking a pdf file). But for API Q the app isn't showing on the list.
Intents filters:
<!--For pdf-->
<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="content"
android:host="*"
android:pathPattern=".*\\.pdf"
android:mimeType="*/*" />
</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: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>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.pdf"
android:scheme="file" />
</intent-filter>
<intent-filter android:priority="999">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data android:host="*" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pdf" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.pdf" />
<data android:pathPattern=".*\\..*\\..*\\.pdf" />
<data android:pathPattern=".*\\..*\\.pdf" />
<data android:pathPattern=".*\\.pdf" />
<data android:scheme="content" />
</intent-filter>
<!--end pdf-->
How can I allow pdf files to be opened with my app in Android Q and above too?
PS: All necessary permissions are taken
I'm using this code for this
<activity
android:name=".OpenPdfActivity"
android:theme="#style/OpenPdfActTheme">
<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:mimeType="application/pdf"
android:scheme="file" />
<data
android:mimeType="application/pdf"
android:scheme="content" />
</intent-filter>
</activity>

Intent-filter abnormal behavior with samsung file browser

I'm creating an intent filter for a specific extension (.infi) for my app. It works correctly with ES file explorer & Solid explorer. However when I open the file with Samsung default file explorer (Device Galaxy Tab S2) it shows a strange message "No application to perform this action", on other device (Note 4) it tries to open the file with Adobe Reader with an error message. Here is my code from manifests file :
<activity android:name=".ImportCollections">
<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:mimeType="*/*" />
<data android:pathPattern=".*\\.infi" />
</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="*/*" />
<data android:pathPattern=".*\\.infi" />
</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="content" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\\.infi" />
<data android:host="gmail-ls" />
</intent-filter>
</activity>
For future references, I looked for another open source app implementing this feature correctly. These guys are doing a great job:
https://github.com/ankidroid/Anki-Android/blob/develop/AnkiDroid/src/main/AndroidManifest.xml
Here is my code that worked (just replace "infi" with your custom extention)
<activity
android:name=".ImportCollections"
android:launchMode="singleTask"
android:parentActivityName=".ManageCollections">
<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="*"
android:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="http" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="https" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="content" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.infi"
android:scheme="file" />
</intent-filter>
<!-- MIME type matcher for .infi files coming from providers like gmail which hide the file extension -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/infi" />
<data android:mimeType="application/x-infi" />
<data
android:mimeType="application/octet-stream"
android:scheme="content" />
<data
android:mimeType="application/zip"
android:scheme="content" />
</intent-filter>
</activity>

How to define an Intent Filter to react to a Drive file pattern?

I'm trying to get my app to react to a .backup file in drive.
I defined my Intent filter as follow
<intent-filter android:label="#string/restoreAppBackup">
<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:host="*" />
<data android:pathPattern=".*\\.backup" />
</intent-filter>
<intent-filter android:label="#string/restoreAppBackup">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.backup"
android:scheme="file" />
</intent-filter>
This works fine once the drive file is downloaded locally, but if I try to open it from the Drive app it doesn't react.
If I remove the scheme filter it starts to react to everything event when it doesn't match the patch pattern...
Any ideas ?

Android Intent-Filter Only Launches App When Email Sent from Some Client Sender Apps

my app's file-intent handles attachments with a custom file extension in emails sent from aol.com, but not from Thunderbird. Has anyone had this issue? I see some comments on mime-type handling. My file type is basically text with a ".hmrx" extension.
Is this a matter of adding something more to the intent-filter?
I don't want my app to be suggested for handling general text files... I don't see the problem:
<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="*/*" />
<data android:pathPattern=".*\\.hmrx" />
<data android:host="*" />
</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:mimeType="application/octet-stream" />
<data android:scheme="content" />
<data android:pathPattern=".*\\.hmrx" />
</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:mimeType="application/octet-stream" />
<data android:scheme="file" />
<data android:pathPattern=".*\\.hmrx" />
</intent-filter>
EDIT:
By the way, I tried adding
<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="content" />
<data android:mimeType="text/plain" />
<data android:pathPattern=".*\\.hmrx" />
</intent-filter>
But then it offers to open regular text files with my app.. which I dont want.
Apparently this is happening because Thunderbird send just about any kind of text as inline instead of as a "real" attachment. Anybody successfully managed this?
Thanks

Custom extension file not opening in my app

I wanted a custom extension file (*.xyz) to be opened through my app. Inside the application manifest file I am writing the following:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http" android:host="*" android:pathPattern=".*\\.xyz" />
<data android:scheme="https" android:host="*" android:pathPattern=".*\\.xyz" />
<data android:scheme="content" android:host="*" android:pathPattern=".*\\.xyz" />
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.xyz" />
</intent-filter>
After that I will install my application on the device and will send a mail containing the Sample.xyz mail as an attachment. When I try to tap on attachment in the mail client to open the attachment then it will give an error called
No app can open this attachment for viewing
Even if when I download the attachment and then try to open it then it will give an error
Can't open file
Can anyone suggest what might be going wrong ?
your filter does not match as it is not http https file and content at the same time - you will need different <intent-filter>'s for this - have a look here:
https://github.com/ligi/PassAndroid/blob/master/src/main/AndroidManifest.xml
and just do what I do for *.pkpass for *.xyz like so:
<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="*"
android:pathPattern=".*\\.xyz"
android:scheme="http" />
</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="*"
android:pathPattern=".*\\.xyz"
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="*"
android:pathPattern=".*\\.xyz"
android:scheme="file" />
</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="*"
android:pathPattern=".*\\.xyz"
android:scheme="content" />
</intent-filter>

Categories

Resources