How I make my app to be shown on available apps that have audio to share

寵の児 提交于 2019-12-14 02:29:27

问题


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



来源:https://stackoverflow.com/questions/43299778/how-i-make-my-app-to-be-shown-on-available-apps-that-have-audio-to-share

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!