是一个试用类似的行为有可能在Android应用

是一个试用类似的行为有可能在Android应用

本文介绍了是一个试用类似的行为有可能在Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid研究与开发(我知道很基本的东西),并有很快我会用一个移植WP7的应用程序到Android将负责一个机会(幸运的是,我可以使用MonoDroid的...)。

I'm new to Android developement (I know very basic stuffs), and there is a chance that soon I'll be tasked with porting a WP7 app to Android (fortunately, I can use MonoDroid...).

现在,应用程序有一个试用的功能(),这对于WP7意味着我可以检查用户是否买了它(这样我就可以使应用程序内的附加功能)或下载免费版。我不希望试用期,我想我的应用程序的自由版限于某些功能。

Now that app has a trial functionality (see here), which for WP7 means that I can check whether the user bought it (so I can enable additional features inside the app) or downloaded the free edition. I do not want the trial to expire, I want a "free edition" of my app to be limited to certain features.

有什么similiar为Android?(并且可以它MonoDroid的做吗?)

Is there anything similiar for Android? (And can it be done on MonoDroid?)

我看着谷歌授权服务,但我不明白如何帮助我。

I've looked at Google Licensing Service, but I don't see how that helps me.

推荐答案

我会去的两个应用程序的解决方案。其中的真实应用程序,它包含了所有的功能。第二个应用程序,只检查许可。

I would go for two apps solution. One "real" application, which contains all the functionality. Second "key" application which only check licensing.

首先应用程序将检查是否安装了应用程序。如果检查为阳性则显示全部内容,使用全部功能。如果关键应用缺少应用程序的行为,如免费的版本。

First application will check if the key application is installed. If the check is positive then display full content, enable all features. If the key application is missing the application behaves like free version.

这也是非常重要的,以检查是否签署这两个应用程序的私钥相同的。如果没有这个检查有人会创建自己的应用程序和解锁功能。这样做的考虑这个片段中,这是我从这个博客了:的

It is also very important to check if the private key that signed both applications is the same. Without this check someone might create their own key application and unlock your functionality. To do so consider this snippet, which I took from this blog: http://www.yoki.org/2010/07/31/creating-a-freepaid-app-pair-for-the-android-market/

protected boolean isProInstalled(Context context) {
  // the packagename of the 'key' app
  String proPackage = "org.yoki.android.pkgname";

  // get the package manager
  final PackageManager pm = context.getPackageManager();
  // get a list of installed packages
  List<PackageInfo> list =
         pm.getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS);

  // let's iterate through the list
  Iterator<PackageInfo> i = list.iterator();
  while(i.hasNext()) {
    PackageInfo p = i.next();
    // check if proPackage is in the list AND whether that package is signed
    //  with the same signature as THIS package
    if((p.packageName.equals(proPackage)) &&
       (pm.checkSignatures(context.getPackageName(), p.packageName) == PackageManager.SIGNATURE_MATCH))
      return true;
  }
  return false;
}

此方法为您提供了灵活一些优势:

This approach gives you few advantages in flexibility:


  • 独立支付领​​域。您可以分配的功能集于不同的应用程序。例如。应用key1的解锁额外的游戏级别A1,A2,A3和应用程序键2解锁等级B1,B2

  • 时授权 - 而不是只检查应用程序的存在。你可以查询它来检查许可证仍然有效。这样,就可以实现时间的许可证。

  • separate paid areas. You can assign sets of features to different key applications. eg. app key1 unlocks additional game levels a1,a2,a3 and app key2 unlocks levels b1,b2
  • time licensing - instead of only checking the existence of key application. You can query it to check if the licence is still valid. That way you can achieve time licences.

这篇关于是一个试用类似的行为有可能在Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 00:34