I am able to fetch the installed or running app list . Now I want to detect in the list is there any music player app present or not?
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);
}
this should do the trick.....
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");
}
}