【问题标题】:How to check if a music player is installed or not?如何检查是否安装了音乐播放器?
【发布时间】:2011-06-17 11:49:32
【问题描述】:

我能够获取已安装或正在运行的应用程序列表。现在我想在列表中检测是否存在任何音乐播放器应用程序?

public void getRunningProcess() {
        List<RunningAppProcessInfo> list2 = am.getRunningAppProcesses();
        listdp = new ArrayList<DetailProcess>();
        for (RunningAppProcessInfo ti : list2) {

            if (ti.processName.equals("system") || ti.processName.equals("com.android.phone")) {
                continue;
            }
            DetailProcess dp = new DetailProcess(this, ti);
            dp.fetchApplicationInfo(packageinfo);
            dp.fetchPackageInfo();
            dp.fetchPsRow(pinfo);
            if (dp.isGoodProcess()) {
                listdp.add(dp);
            }
        }
        Collections.sort(listdp);
        adapter = new ProcessListAdapter(this, listdp);
    }

【问题讨论】:

  • 请显示您目前拥有的代码。
  • 以上是我正在获取正在运行的进程的代码......在我的我需要检测已安装的音乐播放器列表......如果有请指导我任何其他方式.....谢谢..
  • 标签下方有一个“编辑”链接(这些 cmets 正上方)。请使用它将您的代码添加到问题中,以便正确格式化。

标签: android android-music-player


【解决方案1】:

这应该可以解决问题.....

void someFunction(){
    Intent intent = new Intent();
    intent.setType("audio/*");  
    intent.setAction(Intent.ACTION_GET_CONTENT); 
    startActivityForResult(intent,1);
}




    @Override  
        public void onActivityResult(int requestCode, int resultCode, Intent data) {   

            response="";
            String filerealpath=null;

            if (resultCode == RESULT_OK) {  
            System.out.println("mp3 player exists");
    }
    }

【讨论】:

  • 感谢您的帮助.......我需要列出设备中的音乐播放器并将其显示给列表中的用户......如何做到这一点...... ..
猜你喜欢
  • 1970-01-01
  • 2011-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-11
  • 2015-06-29
  • 2011-01-17
  • 1970-01-01
相关资源
最近更新 更多