I need to check the app was installed by apk or from google play.
I have an apk that was downloaded from google play, and also, the app was available on google play. I want to classify two cases.
I already read about this question below, but it is about which app store the application was installed by, And it was not I want.
How does android package manager know what to install from the market place web site?
Is there any method to check the app was installed by apk or not, programmatically by app itself? Any help will be appreciated.
First, find Installer package name, like:
String sourceId = getPackageManager()
.getInstallerPackageName(getPackageName());
Then check the sourceId variable's value, like:
com.android.vending
APK, and installed again:com.google.android.packageinstaller
null
Try this one
PackageManager pm = getPackageManager();
if(pm.getInstallerPackageName(getPackageName()).equals("com.android.vending"){
//App is from google play
//do something
}
app with unknown source will return empty string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With