i tried a lot of things, but i cant make it work, i had an application, and i want when there is an XML in the email, or maybe file explorer or more else, i want my app in the popup of the intent chooser, i cant make it work, anyone has a clue?
btw lets say i make it work, so how i can "handle" when people choose my app in onCreate() to load the information.
here its part of my app i tried a lot of things
<i><application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
<data android:mimeType="application/xml"/>
<data android:scheme="http" android:host="*"
android:pathPattern=".*xml" />
</intent-filter>
</activity>
</application> </i>
Try being a little more broad with your filter, e.g.
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/xml"/>
<data android:scheme="content" android:mimeType="text/*" android:pathPattern=".*\\.xml"/>
<data android:scheme="file" android:mimeType="text/*" android:pathPattern=".*\\.xml"/>
<data android:scheme="http" android:mimeType="text/*" android:pathPattern=".*\\.xml"/>
<data android:scheme="https" android:mimeType="text/*" android:pathPattern=".*\\.xml"/>
</intent-filter>
Other thing you could do is catch the intents in broadcast receiver and rebroadcast as neededed.
this is the code i use, i figure out i need to create another intent filter for view
<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/xml" />
<data android:mimeType="text/xml" />
<data android:mimeType="text/*" />
</intent-filter>
Related
I am trying to extend the copy/paste menu to open a specific activity in my app.
The problem is, that my app appears in some applications, and in most of them do not.
AndroidManifest.xml:
<manifest ....>
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT" />
<data android:mimeType="text/plain" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="text/plain"/>
</intent>
</queries>
<application ...>
<activity
android:name=".component.popupActivity.PopUpActivity"
android:exported="true"
android:theme="#style/Theme.Transparent.SemiBlack">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</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.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:mimeType="text/html"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="application/xhtml+xml"/>
</intent-filter>
</activity>
</application>
</manifest>
Is there anything wrong with my implementation?
I have tested it with WhatsApp, Instagram, Facebook, FB messenger.
Only works with Whatsapp.
Other apps like Translate, Outlook, idealo Shopping, Firefox Focus.
was always able to add their apps to the copy/paste menu.
Firefox Focus is open source, I did not notice anything different in AndroidManifest.xml
After researching, I found the following:
This intent-filter must be added to the activity.
I have tested it with Android 11 and Android 12.
AndroidManifest.xml:
<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>
I am trying to let my app share and handle custom file extension and upon clicking it, it will open my app then I parse it.
I have looked into different ways like LIKE THIS for example and THIS, but clicking on the file from FileBrowser or WhatsApp for example is not detecting my app.
I am using the navigation component if it helps
I am not sure what I am doing wrong, I would appreciate it if someone have a working example.
Thanks.
This is some of the code I tried (I am testing with txt as it is an easy extension) (1)
<intent-filter
android:icon="#mipmap/ic_hp_launcher"
android:label="#string/app_name"
android:priority="999">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern="*.txt" />
</intent-filter>
<intent-filter
android:icon="#mipmap/ic_hp_launcher"
android:label="#string/app_name"
android:priority="999">
<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/txt" />
</intent-filter>
I also tried (2)
<intent-filter
android:icon="#mipmap/ic_hp_launcher"
android:label="#string/app_name"
android:priority="999">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
<intent-filter
android:icon="#mipmap/ic_hp_launcher"
android:label="#string/app_name"
android:priority="999">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.txt"
android:scheme="file" />
</intent-filter>
<intent-filter
android:icon="#mipmap/ic_hp_launcher"
android:label="#string/app_name"
android:priority="999">
<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:scheme="content" />
<data android:mimeType="*/*" />
<!--
Work around Android's ugly primitive PatternMatcher
implementation that can't cope with finding a . early in
the path unless it's explicitly matched.
-->
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
<data android:pathPattern=".*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\.txt" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.txt" />
<!-- keep going if you need more -->
</intent-filter>
and (3)
<intent-filter
android:icon="#mipmap/ic_hp_launcher"
android:label="#string/app_name"
android:priority="999">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:mimeType="text/plain" />
</intent-filter>
I finally my issue, I was testing multiple things at the same time.
I ended up using
<!-- this is needed for apps like whatsapp, it doesn't provide extension, so you can't add path -->
<intent-filter>
<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:mimeType="application/octet-stream"
android:scheme="content" />
</intent-filter>
<!-- this is needed for apps like explorer -->
<intent-filter>
<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="*"
android:mimeType="*/*"
android:pathPattern=".*\\.ext"
android:scheme="content" />
</intent-filter>
If you use mimeType="*/* then check logcat (no filter at all), search for content:// then you see what is the Android sending to your app, then modify the IntentFilter to match what you want. Some apps don't send the extension so using pathPattern was not working with it, Also using schema = content is needed
Thanks #CommonsWare for the help.
I have tried many solution to open application on click of link in browser but nothing is work for me.
I have already tried like this solution.
<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>
Please help me out.
try this its working code.
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
<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="qa.mintshowapp.com"
android:pathPrefix="/m/showroom/mintdetaillanding"
android:scheme="http" />
</intent-filter>
</activity>
I m using following code in my menifest to show the option to user when a relevant url is tried to be open by any source inside the mobile, but it is automatically opening web browser instead of showing my application in options.
What could be the issue?
<activity android:name=".VisitWebPage" >
<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:host="www.mysite.com" />
<data android:pathPattern="/.*" />
</intent-filter>
</activity>
Could you try changing your data tags to:
<data android:scheme="http"
android:host="www.mysite.com" />
<data android:scheme="https"
android:host="www.mysite.com" />
You have to use like this, Its working for me.
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
<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="mysite.com"
android:pathPrefix="/m/showroom/mypage"
android:scheme="http" />
</intent-filter>
</activity>
I have a custom file type with the extension .myext.
I've read android doc and many SO posts to understand how to configure intent filter to associate these files to my app. It works but not properly.
When I use this 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/*" />
<data android:pathPattern=".*\\.myext" />
<data android:host="*" />
</intent-filter>
then it links .myext files to my app, but also every file that has no app assoiated. So I can open .otherext file which I don't want.
Then I found this answer https://stackoverflow.com/a/5097734/575481 which suggest to have multiple intent-filter, So I get :
<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=".*\\.myext" />
</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/*" />
</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=".*\\.myext" />
</intent-filter>
but this doesn't seem to work for me.
What I want is that : my apps opens only .myext files. Do you have any idea ?
Furthermore I will need to open some other file ext (.myext1, .myext2) , but I guess once I get the proper intent-filter, I just have to duplicate it for the others with the extension, right ?
I got it. In my case I am trying to get a .ppp from e-mail and it was fetching any file.
this is the working 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" android:pathPattern=".*\\.ppp" android:mimeType="application/ppp"/>
</intent-filter>
on your activity's onCreate put a breakpoint and check the values in
getIntent()
specifically mData should give you what to write for the android:scheme and mType what to write for the android.mimeType