Is there a way to detect if app was installed with Market or not?
Asked Answered
T

2

24

I am wondering if I am able to detect if my application was installed with Android Market (it's in the download list of the Market and eligible for update checks) or it's not?

It would be a very good point to detect if the app has been installed without, as that can mean it was stolen and installed from SDcard.

Tonsillitis answered 5/7, 2010 at 8:31 Comment(0)
R
29

In your activity do

PackageManager pm = getPackageManager();
String installationSource = pm.getInstallerPackageName(getPackageName());

installationSource will now hold the package name of the app that installed your app.

testing with an app of mine installation source is "com.google.android.feedback" when installed via google market, null if installed via debugger.

Redeemable answered 29/4, 2011 at 14:35 Comment(6)
Does anyone know what the corresponding package name is for the Amazon market?Handbook
Recently Android Market had package "com.android.vending"Ohmmeter
Package name for Amazon Market is com.amazon.veneziaIntertwine
Having checked the Samsung store website, it appears that this would also be null for apps installed via that method.Lovable
Link to the Samsung Developers Forum discussion about the matter.Castellany
List<String> list = new ArrayList<>(Arrays.asList("com.android.vending", "com.google.android.feedback")); if (installationSource != null && list.contains(installationSource)) return true;Albumen
S
0

If you're not root (and have access to Market database), I don't think it's possible.

Superabundant answered 5/7, 2010 at 10:22 Comment(1)
they should provide a contenrprovider with the dbTonsillitis

© 2022 - 2024 — McMap. All rights reserved.