Android
android 단말기내 어플리케이션(앱) 설치 여부 확인 방법
잘구운토스트
2016. 12. 5. 16:56
테스트 환경
Android Studio 2.1.2
Target SDK 24 ( Android 7.0 Nougat)
getLaunchIntentForPackage()를 사용하면 간단하게 구현할 수 있으며, API레벨 3이라 저사양 폰도 걱정 없을 듯하다.
구현방법은 아래 소스를 참고하면 된다.
찾는 앱이 없을 경우 Play Store로 이동하며, 있을 경우 해당 앱을 실행하는 소스이다.
PACKAGE_NAME는 단말기내에 찾을 앱 패키지명을 넣어 주면 된다.
1 2 3 4 5 6 7 8 | Intent launchIntent = getPackageManager().getLaunchIntentForPackage("PACKAGE_NAME"); if (launchIntent == null) { // 단말기 내에 어플리케이션(앱)이 설치되어 있지 않음. Intent intent = new (Intent.ACTION_VIEW, Uri.parser("market://details?id=" + "PACKAGE_NAME")); startActivity(intent); // 앱이 설치되어 있지 않은 경우 Play스토어로 이동 } else { // 단말기 내에 어플리케이션(앱)이 설치되어 있음. startActivity(launchIntent); // 앱이 설치되어 있으면 앱 실행. } | cs |