Search code examples
javaandroidandroid-manifestintentfilter

how to add myApp to complete action using?


when you click on a video android give you some suggestion app to open the video i wnat to add my app to the list. name of the list is complete action using and this doc is related https://developer.android.com/training/basics/intents/filters.html but i am beginner and dont know how to use the doc for video

<activity android:name="ShareActivity">
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
        <data android:mimeType="image/*"/>
    </intent-filter>
</activity>

and please guide me how to handle the intent in activity


Solution

  • Put this code into your manifest in your activity tag :

        <intent-filter tools:ignore="AppLinkUrlError">
            <action android:name="android.intent.action.VIEW" />
    
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
    
            <data android:mimeType="video/*" />
        </intent-filter>
    

    It will show your app into a suggestion list whenever user selects a video file from his phone. ALthough, you need to handle the further actions in your videoplayer activity.

    Because this tag will only help you getting your into a suggestion list, to play a selected video, you have to use intent to get the selected video uri. You can find the examples of playing a video file like this on the internet easily.