본문 바로가기

ANDROID의 속삭임

[android][TIP]외부 어플리케이션 실행.

* 묵시적 호출 
Intent intent = getPackageManager().getLaunchIntentForPackage( " 패키지 이름" );
startActivity(intent);

* 명시적 호출
ComponentName comp = new ComponentName("패키지명","패키지명.액티비티명");
Intent intent = Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER)
intent.setComponent(comp);
startActivity(intent);

* 최상위 액티비티를 실행 하고 싶은 경우
Intent intent = getPackageManager().getLaunchIntentForPackage( "패키지 명" );

intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

startActivity(intent);