I'm developing an app for android. Nowadays there is a lot of stores that illegally distribute android paid apps by free.
Is there any snippet of code could I write to prevent my android app being downloaded from any other store which is not google play? For example, when the user try to open the app,Showing a message like "You need to buy this app in google play" and then close the app?
Check packageInstallerName
The simplest way to check if your app was downloaded from Google Play is to check if packageInstallerName is empty as in example below:
String installer = getPackageManager().getInstallerPackageName(
"com.example.myapp");
if (installer == null) {
// app was illegally downloaded from unknown source.
}
else {
// app was probably installed legally. Hooray!
}
but as we read here: https://stackoverflow.com/a/36299631/4730812
You should not use PackageManager#getInstallerPackageName to check if the app was installed from Google Play or for licensing purposes for the following reasons:
1) The installer packagename can change in the future. For example, the installer package name use to be
"com.google.android.feedback" (see [here][2]) and now it is
"com.android.vending".
2) Checking the installer packagename for piracy reasons is equivalent to using Base64 to encrypt passwords — it's simply bad
practice.
3) Users who legally purchased the app can side-load the APK or restore it from another backup application which doesn't set the
correct installer packagename and get a license check error. This will
most likely lead to bad reviews.
4) Like you mentioned, pirates can simply set the installer packagename when installing the APK.
So there's only two good ways to prevent Android app being downloaded outside Google Play Store:
Adding licence to your app;
Basically ensures that the application has been bought by the user using device:
Android Reference:
https://developer.android.com/google/play/licensing/index.html
Setting Up for Licensing
Adding Licensing to Your App
In-app Billing
Make your application free and add built-in purchases.
In-app Billing is a Google Play service that lets you sell digital
content from inside your applications. You can use the service to sell
a wide range of content, including downloadable content such as media
files or photos, virtual content such as game levels or potions,
premium services and features, and more. You can use In-app Billing to
sell products as:
Standard in-app products (one-time billing), or
Subscriptions (recurring, automated billing)
When you use the in-app billing service to sell an item, whether it's
an in-app product or a subscription, Google Play handles all checkout
details so your application never has to directly process any
financial transactions. Google Play uses the same checkout backend
service as is used for application purchases, so your users experience
a consistent and familiar purchase flow.
Any application that you publish through Google Play can implement
In-app Billing.
Android Reference:
In-app Billing
Implementing In-app Billing
Preparing Your In-app Billing Application
Hope it will help
Related
I have a web app that works in conjunction with a locally installed desktop app.
Users have the option to upgrade to a premium membership for a monthly fee.
Both apps provide 100% of the functionality of my product(this is important for my question).
To widen my distribution I'm considering adding an android app.
Now, I know that Google generally forces android apps to use their in-app billing.
However, reading the developer terms I see this:
Developers offering products within another category of app downloaded
on Google Play must use Google Play In-app Billing as the method of
payment, except for the following cases: Payment is solely for
physical products
Payment is for digital content that may be consumed
outside of the app itself (e.g. songs that can be played on other
music players).
It seems like the bolded part applies to my product, since
it's not a game
the premium membership can be consumed entirely without the android app(using my desktop or web app)
Am I allowed to publish my android app to Google Play using my own payment processor or will google crack down on me?
You should be fine.
As long as the purchase isn't for something that can only be used inside the app, you're good. Since your purchase option applies across all platforms, you fall under that exception.
Of course, Google being Google, they could take down your app. However, you should just need to appeal that decision and talk to an actual person to get it sorted out.
We are going to build a mobile app for iOS and Android (might build a web app later) where users can upload videos and their friends and followers can watch them. The videos can be either free or also be tagged with a price. If I tag a video with $1 when uploading it, my friends and followers will have to first pay $1 to watch and after paying that $1 they can watch it any time after that.
My client wants to use Authorize.net to do the payments. In iOS there are restrictions like we must use IAP for such feature. Similarly is there any restrictions on Android as well, that we must use Google In-app Billing or is it OK to use Authorize.net to do the payments?
Taken from this page:
Payments
Apps that employ in-store or in-app purchases must comply with the
following guidelines:
In-store purchases: Developers charging for apps and downloads from
Google Play must use Google Play’s payment system. In-app purchases:
Developers offering products within a game downloaded on Google Play or providing access to game content must use Google Play In-app
Billing as the method of payment.
Developers offering products within another category of app downloaded on Google Play must use Google Play In-app Billing as the
method of payment, except for the following cases:
Payment is solely for physical products
Payment is for digital content that may be consumed outside of the app itself (e.g. songs that can be played on other music players).
In-app virtual currencies must only be used within the app where they were first purchased.
Developers must not mislead users about the apps they are selling nor about any in-app services, goods, content, or functionality
offered for purchase. If your product description on Google Play
refers to in-app features that may require a specific or additional
charge, your description must clearly notify users that payment is
required to access those features.
So I guess the answer is no, you have to use Google Play in-app billing if you want to publish the app in the play store. But the policy states that digital content under some circumstances is excluded, I guess this applies to videos as well, although I'm not to sure about it. Depends on whether the videos can be played outside of the app (at least so it seems).
How to set app billing to buy app just once per account ??
Can't find any examples with such situation. If possible provide some external links to see.
When you say 'upgrade' you mean within the app, meaning the user has already downloaded the app for free.
This could be accomplished by in app purchases (tied to Google account if you're using the Google Play API) or by purchasing a separate app (i.e. PRO version) which interfaces with the current app.
Here's the docs for in app purchases:
http://developer.android.com/google/play/billing/billing_overview.html
And here's another SO question if you want to go the PRO/unlocker route:
How can I use the paid version of my app as a "key" to the free version?
Can anyone explain how does in-app billing process works for Android?
Do I need to upload two different apk (free and paid) to Play store and link buy button click in free app to paid version on Play store, but in this case will free app get replaced with paid app when user purchases paid one? How to achieve this?
If I give buy button in my free app which enabled purchase of paid full version (extra features) then how does this purchase works? Is it that upon activity startup I get some event when will tell me if app is purchased or not. Based of which I can enable paid features in my code. If yes Will this kind of logic work when user is offline? and how?
Appreciate if someone could clear my confusion with sample code. I have successfully run Google's sample code but not able to understand if I upload my app as free app how and when do I need to mention amount paid features?
Do I need to upload two different apk (FREE & paid) to play store .
This depends on the use case. If you want to give your users different app that has limited and Pro features that differs majorly then you should put two different apk's in market.
Otherwise , If your app has Free and Paid content you should include In-App purchases.
in this case will free app get replaced with paid app when user
purchases paid one ? How to achieve this.
No , Your app won't get replaced , you will only get payment successful/failed response from Google play , you have to save that information in your app shared preferences and manage your app flow accordingly.
If I give buy button in my free app which enabled purchase of paid
full version (extra features) then how does this purchase works?
Your application accesses the In-app Billing service using an API that is exposed by the Google Play app that is installed on the device. The Google Play app then conveys billing requests and responses between your application and the Google Play server. In practice, your application never directly communicates with the Google Play server for purchases. Instead, your application sends billing requests to the Google Play application over interprocess communication (IPC) and receives responses from the Google Play app. Your application does not manage any network connections between itself and the Google Play server.
If yes Will this kind of logic work when user is offline? and How.
To complete in-app purchase requests, the Google Play app must be able to access the Google Play server over the network. But after initiating a purchase request , you can save your payment response in shared preference for maintaining offline status.
Appreciate if someone could clear my confusion with sample code. I
have successfully run google's sample code but not able to understand
You should first start by reading the API docs Google Play In-app Billing and Selling In-app Products ,
if I upload my app as free app how and when do I need to mention
amount paid features ?
After that follow the steps to create In-App products on Google play account and run the API sample for those products.(There are plenty of tutorials online). Also you can take a look at official website for Establishing In-app Billing Products for Sale
Enjoy!
I am going to be supporting In-App billing/ purchases in my app.
From what I have read, it seems the Play Store app must be installed on the device in order to do In-App billing. I have 2 Android devices for testing. Both are missing the Play Store app. I am sure this situation will exist for users of my app.
Question: What does an Android developer do when their app supports In-App billing but the Play Store app is not installed on the device?
As far as I know, there is no way to do a market payment if they do not have the market.
You could see if the market is installed and if not, either provide a clear message saying so, possibly with instructions on how to get it, or link to some other payment method like paypal in a web browser.