2011년 3월 17일 목요일

[Android] 현재 내 어플에서 다른 어플리케이션 실행시키기..

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

List appList = pm.queryIntentActivities
(mainIntent, 0);
Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));
int temp=0;
for(int i=0; i Log.v("RJ",appList.get(i).loadLabel(pm).toString());
if(appList.get(i).loadLabel(pm).toString().equals("Calendar"))
temp = i;
}
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

i.setComponent(new ComponentName(appList.get (temp).activityInfo.applicationInfo.packageName, appList.get(temp).activityInfo.name));
startActivity(i);

댓글 없음:

댓글 쓰기