Last active
December 14, 2015 00:59
-
-
Save drakestone/5002888 to your computer and use it in GitHub Desktop.
PackageManager 에서 application package 명 얻어내기.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final PackageManager pm = getPackageManager(); | |
List<ApplicationInfo> applications = pm.getInstalledApplications(PackageManager.GET_META_DATA); | |
for (ApplicationInfo appInfo : applications) { | |
PackageInfo pkgInfo; | |
try { | |
pkgInfo = pm.getPackageInfo(appInfo.packageName, | |
PackageManager.GET_META_DATA | | |
PackageManager.GET_PERMISSIONS); | |
// if ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { | |
// continue; | |
// } | |
Log.d(TAG, pm.getApplicationLabel(pkgInfo.applicationInfo) + | |
" : " + | |
pkgInfo.applicationInfo.packageName); | |
} catch (NameNotFoundException e) { | |
e.printStackTrace(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
중간에 주석을 풀면 시스템에 설치된 package 는 표시 안합니다.