-2

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

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

1 回答 1

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");
    }
    }
于 2011-06-17T12:32:07.617 回答