Register to be able to open files of custom type. Say i have .cool files, and if the user tries to open it, Android asks if they would like to open it with my application. How?
To set a default appFind and tap Settings > Apps & notifications > Default apps. Tap the type of app you want to set, and then tap the app you want to use as default.
Open the Control Panel. In the Control Panel, click the Default Programs option. Click the Associate a file type or protocol with a program option. In the Default apps window, scroll to the bottom and select Choose defaults by file type.
You can add the following to the AndroidManifest.xml file inside the activity that has to open the file (pdf in our case)
<intent-filter > <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/pdf" /> </intent-filter> Make sure you specify the proper mime format. The user will be prompted to choose your app if she wants to open the "pdf" file.
Check also Android intent filter: associate app with file extension for more details.
I think that you don't choose that. This is handle by the system. Same thing when you send an intent to be handled by a map, If you have skyfire for instance, the system pops up a window an you can choose the application and choose if you want it to always open this kind of file.
Unless of course if your application is the only one to open this kind of file.
Edit
I think if you want your app to say "hey I'm able to open these .cool files", you need to set up <intent-filters> with a tag <data> and specificy the mimeType or Uri. Check here for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With