1

Is there any way to scan .apk files of other apps from my own app without root access? There should be because there are apps like APK Extractor that offer you to get .apk of any installed application. Best thing is, APK Extractor doesn't require root access.

I tried doing this by using ProcessBuilder and calling command pm list packages to get installed packages, then I'd run pm path com.package.name to get path of each .apk. I get valid paths but when I try to open it using File apkFile = new File(apkPath); I get

java.io.FileNotFoundException: /data/app/some.app.package/base.apk
open failed: ENOENT (No such file or directory)

which basically means I don't have right permissions to read that file.

Drag0
  • 8,438
  • 9
  • 40
  • 52

2 Answers2

2

I found solution in another question, here is direct link to answer in another thread.

I also copied answer here for lazy people.

  1. First you get all installed applications,
  2. For each one, get public source directory.
  3. copy the file to the SDCard.

Note: No need to be rooted.

Here is the snippt code:

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);
for (Object object : pkgAppsList) {
    ResolveInfo info = (ResolveInfo) object;
    File file = new File(info.activityInfo.applicationInfo.publicSourceDir);
    // Copy the .apk file to wherever
}
Community
  • 1
  • 1
Drag0
  • 8,438
  • 9
  • 40
  • 52
0

You need SU access if you want to access this APK. Read about this more here. If just using regular phone, Android OS won't let you access other APK because of security reasons. Also, are you sure that user has actually installed on phone that other APK?

Dejan
  • 3,046
  • 3
  • 28
  • 43
  • Did you read the question? I wrote about this APK Extractor app that allows you to access .apk files of other applications. Check it out, it doesn't need root access. – Drag0 Feb 24 '16 at 13:38
  • If you want this access you need this priviledge, I do not know how can you access it differently if Android won't let you. – Dejan Feb 24 '16 at 13:39
  • Like you said, you can only access process list and nothing more. – Dejan Feb 24 '16 at 13:39
  • Ok, but do you see this application "APK Extractor"? It gets access to other .apk files without root access. How do you explain that then? – Drag0 Feb 24 '16 at 14:08
  • Give me link to this application. – Dejan Feb 25 '16 at 08:43
  • Maybe this http://stackoverflow.com/questions/19311690/copy-system-app-apk-to-sdcard-programmatically – Dejan Feb 25 '16 at 13:14
  • I found a solution in some other question. – Drag0 Feb 25 '16 at 13:21