Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. import android.content.pm.ApplicationInfo;
  2.  
  3. if ((ApplicationInfo.FLAG_SYSTEM & myApplicationInfo.flags) != 0)
  4. // It is a pre embedded application on the device.
  5.  
  6. private String getAllPreInstalledApplications() {
  7.  
  8. String allPreInstalledApplications = "";
  9.  
  10. PackageManager pm = getPackageManager();
  11. List<ApplicationInfo> installedApplications = pm
  12. .getInstalledApplications(PackageManager.GET_META_DATA);
  13.  
  14. for (ApplicationInfo applicationInfo : installedApplications) {
  15. if (isApplicationPreInstalled(applicationInfo)) {
  16. allPreInstalledApplications += applicationInfo.processName + "n";
  17. }
  18. }
  19.  
  20. return allPreInstalledApplications;
  21. }
  22. private static boolean isApplicationPreInstalled(ApplicationInfo applicationInfo) {
  23. if (applicationInfo != null) {
  24. int allTheFlagsInHex = Integer.valueOf(
  25. String.valueOf(applicationInfo.flags), 16);
  26. /*
  27. If flags is an uneven number, then it
  28. is a preinstalled application, because in that case
  29. ApplicationInfo.FLAG_SYSTEM ( == 0x00000001 )
  30. is added to flags
  31. */
  32. if ((allTheFlagsInHex % 2) != 0) {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement