Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.pm.ApplicationInfo;
- if ((ApplicationInfo.FLAG_SYSTEM & myApplicationInfo.flags) != 0)
- // It is a pre embedded application on the device.
- private String getAllPreInstalledApplications() {
- String allPreInstalledApplications = "";
- PackageManager pm = getPackageManager();
- List<ApplicationInfo> installedApplications = pm
- .getInstalledApplications(PackageManager.GET_META_DATA);
- for (ApplicationInfo applicationInfo : installedApplications) {
- if (isApplicationPreInstalled(applicationInfo)) {
- allPreInstalledApplications += applicationInfo.processName + "n";
- }
- }
- return allPreInstalledApplications;
- }
- private static boolean isApplicationPreInstalled(ApplicationInfo applicationInfo) {
- if (applicationInfo != null) {
- int allTheFlagsInHex = Integer.valueOf(
- String.valueOf(applicationInfo.flags), 16);
- /*
- If flags is an uneven number, then it
- is a preinstalled application, because in that case
- ApplicationInfo.FLAG_SYSTEM ( == 0x00000001 )
- is added to flags
- */
- if ((allTheFlagsInHex % 2) != 0) {
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement