My code looks at the package installer, as per this thread on Stack Overflow. It may not be the most accurate of methods, but in my testing it worked fine.
When looking at Android App piracy, I keep comparing it to piracy of videos & music. You can’t beat it by DRM. You can’t beat it by sending takedown notices to everyone who dares copy your content. While you have a legitimate right to control the content, it’s just not possible to completely lock things down.
The alternative approach is to let people pirate your app as much as they like - but make it really easy to pay for it, and provide extra value to those who do. I really think this is the best way to go.
So if you’re browsing on Google Play, and see an app for $3 that you’d like to download, there are two options. Either click “Buy”, click “Confirm”, and you’ve got it - with unlimited automatic updates. Or, go across to your computer, type in “app name apk”, sift through a few dodgy sites to find the right APK, somehow send the URL or APK across to your phone, download & install the file. Then you’ve gotta hope that somebody didn’t add malware to the apk (admittedly unlikely), and if you want any future updates you’ve got to go searching for them manually.
Looking at this scenario, it’s hard to see many users going to the extra effort to pirate your app. Sure, if they’re in a country with no Google Play purchase support, or if they don’t have a credit card. But the vast majority of users have an easy & painless way to purchase your app - and that’s what really matters.
Contrast this with the video & music situation. In Australia it is ridiculously hard to purchase movies & music online. Piracy is by far the easiest way to get hold of entertainment (unless you’ve forked out the money to own an iDevice and want to use iTunes). People don’t pirate stuff just because they want it for free - it’s also because of the convenience.
Anyway, that’s my rant for now I realise the situation is different if your app has a server side with maintenance costs. But for most client-side apps, I think convenience is key.