问题
I just developed an Android App which I´d like to distribute for free.
In order to be able to earn some money for my work, I´d like to add some adverts or notification to the app. If a user decides to donate some money, he will receive an unlock code for the "donate" version using some kind of unlock code.
Is there any "best practice" for implementing this in Android?
Thanks!
回答1:
Yes, there is. It's in-app billing. :-)
*edited because of the moderator comment.
After reading the link above, you'll understand that you can implement various packages that will provide, each, the desired functionality. In your case, you will have "donation products" (packages) that the user will buy. Some of the details that need to be addressed here, IMHO:
Most simple apps are $1, $2, $5, $10 and $20, but you can provide higher values as well, of course. Comparing to the multiple-app pattern, this has the advantage of simplified code logic, since you manage everything inside one code branch, and there is no need to fiddle with different applications.
Since you're providing donation packages, it's logical that the user can donate that given quantity more than once. Thus, you should just make sure that the donation package --- the product you add in the Market console --- is unmanaged.
That's the general concept together with the two main concerns about your particular case.
Note: the reason I gave the original, very simple answer (still, I do not disagree with the moderator comment) is because the in-app billing is very simple to implement. There is not much to be said really. Try it!
回答2:
I have used this approach:
- I release my free android app called "My App"
- I release an empty paid app called "MyApp Donate" (it will have just an activity with some text like "thank you for donating...bla bla")
Let's assume that in "My App" you will show ads, you can have somewhere a button "Remove Ads by donating" which takes the user to the market page for "My App Donate".
In My App you decide if you have to show or not an ad based on the fact that the package "My App Donate" is installed or not.
It sounds complicated, but it's super easy to implement. You can check if a package is installed with the following code:
public static boolean isPackageInstalled (final Context ctx, final String packageName) {
boolean result = false;
try {
final PackageManager pm = ctx.getPackageManager();
final PackageInfo pi = pm.getPackageInfo(packageName, 0);
if (pi != null && pi.applicationInfo.enabled)
result = true;
}
catch (final Throwable e) {
if (Dbg.IS_DEBUG) Dbg.debug("Package not installed: "+packageName);
}
return result;
}
ps. in-app billing is not so easy to integrate, moreover your app will be visible ONLY in the countries where in-app is supported. it's not worth it in your case.
回答3:
You can do this through the Android Marketplace with in-app billing. There are also a lot of apps that offer a free version and a paid version, where the paid version has more features or fewer ads.
来源:https://stackoverflow.com/questions/8247222/what-is-the-best-practice-for-unlocking-app-features-to-the-user-in-android