将我的应用程序在Android的编程默认的音乐播放器 [英] Set my app as default music player in android programatically
问题描述
当我们点击一个MP3文件,我们得到了弹出窗口显示默认的应用程序可以播放该文件。
When we click a mp3 file we get the popup window showing default apps which can play that file.
我如何我的应用程序添加到列表?
How can I add my app to that list?
有关发展我提到的应用程序的 TUTS上的教程+ 。
For developing the app I referred a tutorial on tuts+.
我使用的是被称为服务的播放器服务的参考的一款Android开发者博客文章。
I am using a service called player service referring to a android-developers blog post.
我已经加入以下code到<服务与GT;
定义清单文件
I have added following code to the <service>
definition in the manifest file
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="file"/>
<data android:mimeType="audio/*"/>
<data android:mimeType="application/ogg"/>
<data android:mimeType="application/x-ogg"/>
<data android:mimeType="application/itunes"/>
</intent-filter>
我应该设置什么MIME类型,使我的应用程序设置为默认应用程序之一?
What mime type should I set to make my app as one of the default apps?
我无法看到我的应用程序在弹出窗口中。
I am not able to see my app in the popup window.
推荐答案
这是不可能以编程方式设置你的应用程序为默认的音乐播放器。它必须由用户来完成,当它在你指的是弹出式窗口的显示。
It's not possible to set your app as default music player programmatically. It has to be done by the user when it's shown in the popup window you're referring to.
要得到你的应用有,你可以参阅在(过时)的Android音乐播放器的清单
To get your app there you could refer to the manifest of the (outdated) android music player
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content"/>
<data android:host="media"/>
<data android:mimeType="audio/*"/>
<data android:mimeType="application/ogg"/>
<data android:mimeType="application/x-ogg"/>
<data android:mimeType="application/itunes"/>
</intent-filter>
您从那里所需要的主要商品是&lt;作用&GT;
元素。请参见意图过滤器如果不采取行动了解详细信息,这里的问题。附加&lt;数据方式&gt;
元素可能会派上用场了更广泛的场所,以支持
The main item you need from there is the <action>
element. See intent filter without action for more details to the issues here. The additional <data>
elements might come in handy for a wider range of locations to support.
这篇关于将我的应用程序在Android的编程默认的音乐播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!