Get package name of APK

wolfgentleman

Member
Dec 13, 2013
14
0
0
Visit site
I am making a "force installer" that copies the selected APK to /data/app or /system/app, depending on the user's choice, and fix the permissions and ownership.
However, this leaves one thing - it should be renamed like this: {PACKAGE_NAME}-{1|2}.apk
So I have been searching on how I can extract the package name from the APK. All I have been able to find is how to do it with the SDK (aapt) and how to get the package name(s) of already installed apps. So how can I get the package name from the APK on Android?

Sincerely,
Patrick Thomas (Timberwolf)
Timberwolf Programmers Owner & Founder
---- Sent from Tapatalk ----
 

TypeOverride

Member
Sep 1, 2014
10
0
0
Visit site
You want to extract the package name from the APK in code ? If yes it should work with the package manager of the android API

PackageManager packageManager = getPackageManager();

Maybe the AndroidManifest.xml is helpful too ?

or do i not understand correctly ?
 

wolfgentleman

Member
Dec 13, 2013
14
0
0
Visit site
You want to extract the package name from the APK in code ? If yes it should work with the package manager of the android API

PackageManager packageManager = getPackageManager();

Maybe the AndroidManifest.xml is helpful too ?

or do i not understand correctly ?
Well, yes... but how would I select an arbitrary APK for the package manager? I would think extracting the manifest would be messy...

Say the APK is /sdcard/download/somefancyapp.apk, I want to retrieve the package name from it.
 
Sep 18, 2014
12
0
0
Visit site
PackageManager class have the following method:

public PackageInfo getPackageArchiveInfo (String archiveFilePath, int flags)

Retrieve overall information about an application package defined in a package archive file.

Did you tried it?
 

wolfgentleman

Member
Dec 13, 2013
14
0
0
Visit site
PackageManager class have the following method:

public PackageInfo getPackageArchiveInfo (String archiveFilePath, int flags)

Retrieve overall information about an application package defined in a package archive file.

Did you tried it?
No, I didn't. Let me try that now.

Sincerely,
Patrick Thomas (Timberwolf)
Timberwolf Programmers Owner & Founder
---- Sent from Tapatalk ----
 

Forum statistics

Threads
943,170
Messages
6,917,628
Members
3,158,860
Latest member
smokedog87