본문 바로가기

Android

checking installed app

http://dlucky.tistory.com/109

PackageManager pm = getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);
Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));

int temp=0;
for(int i=0; i<appList.size(); i++) {
    Log.v("RJ",appList.get(i).loadLabel(pm).toString());
    if(appList.get(i).loadLabel(pm).toString().equals("Calendar"))
    temp = i;
}

Intent in = new Intent();
in.setAction(Intent.ACTION_MAIN);
in.addCategory(Intent.CATEGORY_LAUNCHER);
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
in.setComponent(new ComponentName(appList.get(temp).activityInfo.applicationInfo.packageName, appList.get(temp).activityInfo.name));

startActivity(i);

'Android' 카테고리의 다른 글

javascript to java interface on android  (0) 2013.10.08
security and permissions  (0) 2013.10.08
content providers  (0) 2013.10.08
databases  (0) 2013.10.08
files  (0) 2013.10.08