如何检查是否安装了音乐播放器?

时间:2011-06-17 11:49:32

标签: android android-music-player

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

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);
    }

1 个答案:

答案 0 :(得分: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");
    }
    }