public String getPackageNameByAPK(String _strAPKPath, Context _activityORservice)
Java Source CodeThe Java language source code with android.content.pm.PackageManager to get the package name from a .apk file is shown in this post for online learning purposes.
Android apps are supplied in .apk files(even if you download from the Play store) which contain all information needed to install an app on an Android smartphone.
Once an app is installed on the phone it is identified by a unique package name; the package name format is:
- com.usrax.ca
- com.honestitconsultancy.patric
- mysymphony.pmi.com
This value is taken from the Manifest.xml file which is already present inside the .apk file of an Android application(app).
If we search "get package name from .apk" on Google we won't be able to find the source code to do this on the first page; almost everyone tries to tell us that this will be done through the command line.
This post will answer the following question:
Android, get the package name from apk file in your program
Package Archive files
There is a little twist behind these search results, is there another name for .apk files?Yes sir, the full name of .apk files is "Package Archive". You can say that's the legal name .apk is only a nickname used by the Linux OS (Android is a Linux) and developer community.