How I make my app to be shown on available apps th

2019-07-30 08:16发布

问题:

I'm building a app with sounds to be shared via WhatsApp, it's almost done, however is missing a single thing, that I already tried everything, but nothing seems to work. I wanna that when the user click on share button of own whatsApp (the one that is a clip) my app be listed on list of possible apps to do that action, this way:

I already tried use a intent filter on a activity like

<intent-filter>
                <action android:name="android.intent.action.SEND" />
                <data android:mimeType="audio/*" />
            </intent-filter>

and too

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <data android:mimeType="audio/*" />
            </intent-filter>

however my app wasn't shown, I already saw that is possible with other apps, I'm just doing something wrong. How I can do to make my app be listed? Anyone knows? Really Thx.

Note - the image is just a example, not a real one 'cause I can't print the screen of a real device, then I found this one on internet :(

EDIT 1 I tried this way too, but did not work

<activity
        android:name=".activities.HomeActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.PICK" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="audio/*" />
    </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="audio/*" />
    </intent-filter>
</activity>

回答1:

<intent-filter>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="audio/*" />
        </intent-filter>

//and too

<intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="audio/*" />
        </intent-filter>

Replace With below code

//this is to get text from other app

        <intent-filter>
            <action android:name="android.intent.action.SEND" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="audio/*" />
        </intent-filter>

For more idea here is an official document form android : https://developer.android.com/training/sharing/receive.html