我如何使我的应用程序显示在可以共享音频的可用应用程序上 [英] How I make my app to be shown on available apps that have audio to share

查看:100
本文介绍了我如何使我的应用程序显示在可以共享音频的可用应用程序上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个声音,可以通过WhatsApp共享的应用程序,这差不多完成了,但是却遗漏了一件事情,那就是我已经尝试了一切,但似乎没有任何效果. 我想当用户单击自己的whatsApp的共享按钮(即剪辑的共享按钮)时,将我的应用以这种方式列出在可能的应用列表中:

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>

也是

<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 :(

编辑1 我也尝试过这种方法,但是没有用

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>

推荐答案

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

//也

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

替换为以下代码

//这是要从其他应用获取文本

//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>

要了解更多信息,请参阅android的官方文档: https://developer. android.com/training/sharing/receive.html

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

这篇关于我如何使我的应用程序显示在可以共享音频的可用应用程序上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆