What is the best practice for unlocking app features to the user in Android?

血红的双手。 提交于 2019-11-30 19:46:35

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:

  1. 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.

  2. 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!

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!