Example: when you click a button to upload an image, you get the dialog to choose a file. Then you can select an app you want to choose it. How can I make my app appear in that dialog?
You need to add an Intent filter to your manifest file in the activity you want to handle the upload. For example: I have an Activity that handles image import, this is what I wrote.
activity android:name="com.ImportTheme">
<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:scheme="file" android:mimeType="image/*" />
</intent-filter>
</activity>
As you can see, you need to add mime type that suitable to what you looking for, at my example, I want only pictures - png, jpg etc.
Check in the next link, you have a list of mime types.
Add the following intent filters to your Activity where you want the picking to take place:
<intent-filter >
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.OPENABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
The first one handles an Action Pick, and the second one Get Content.
You may want to change your mimeType to restrict selection a little. The one I provided will put your app in the selector for every type of file.
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