Home » Android » android – How can I launch an APK from a privileged application?-Exceptionshub

android – How can I launch an APK from a privileged application?-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I’m writing an Android app which will run as a privileged app. Suppose there is an APK file already in storage on the device. How can I programmatically launch this APK? It’s okay if there’s a separate installation step and I can give my app whatever permissions it needs, just at the end of the day I need to launch the app that’s in that APK.

I used something like the code in this answer to install the APK and I think it worked, because the package shows up (in one form or another) when I run adb shell pm list packages. But none of the solutions I found online to actually start the activity have worked:

  • PackageManager.getLaunchIntentForPackage() returns null, as in this question.
  • queryIntentActivities() returns an empty list.
  • The app in question does have the CATEGORY_LAUNCHER tag in its manifest.
How to&Answers: