7

I've got an app which I would like to distribute through the market place and also from my own site. How do I, using only one build and one key, check to see if the app was downloaded from the market place or not?

This question is answered by having the code signed with different keys, but we ideally want a single build.

Community
  • 1
  • 1
Martyn
  • 16,432
  • 24
  • 71
  • 104

5 Answers5

4

packageManager.getInstallerPackageName(context).equals("com.google.android.feedback")

http://developer.android.com/reference/android/content/pm/PackageManager.html#getInstallerPackageName(java.lang.String)

Andy McSherry
  • 4,676
  • 3
  • 26
  • 36
  • 3
    This might not be a viable solution, as [some developers are reporting](http://groups.google.com/group/android-developers/browse_thread/thread/d3c0ac0748e38132) that `getInstallerPackageName()` does not always return the same value (or any value at all) when the application is installed via the Market. – Paul Lammertsma Nov 20 '11 at 20:32
2

It seems that this can't be done.

Martyn
  • 16,432
  • 24
  • 71
  • 104
  • 1
    Note that it only can't be done given the OP's constraints. It could done by signing the Market build with a unique key, and comparing a checksum of the key against a stored value inside the app. Personally, I prefer to customize by build script for release vs. debug builds. – Paul Lammertsma Nov 20 '11 at 20:39
1

On my Android 1.5 handset only applications installed via Market are listed in "My downloads" in Market App, so the question is if you can retrieve that list in runtime. I don't know if it's the same with Android 2.x.

matm
  • 7,059
  • 5
  • 36
  • 50
1

Paid apps from the market can use the Android Licensing Module to determine if they are buyed from the market. But for free apps i don't know a solution

http://developer.android.com/guide/publishing/licensing.html

ludwigm
  • 3,363
  • 3
  • 28
  • 36
0

I don't know if this really correlates or not, but if you can read /data/system/packages.xml market apps seem to have installer="com.google.android.feedback" while those bundled with the system build and those locally compiled do not.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117