Check this link here. Then
PackageManager pm = getPackageManager();
String installationSource = pm.getInstallerPackageName(getPackageName());
When installed from the marked, the installationSource
will return something like com.google.android%
or com.android.vending%
. However this changes and you have to maintain (support) it in case of a change - otherwise it will return null (from debugger) or some other package name, from some other application (the undesired ones :))