Is this behavior possible in Android apps

I am new to Android development (I know very simple things), and there is a chance that I will soon be instructed to port the WP7 application to Android (fortunately, I can use MonoDroid ...).

Now this application has trial functionality ( see here ), which for WP7 means that I can check whether the user bought it (so that I can enable additional functions inside the application) or download the free version. I don’t want the lawsuit to expire, I want the "free version" of my application to be limited to certain functions.

Is there anything similar for Android? (And can this be done on MonoDroid?)

I looked at the Google licensing service, but I don’t see how this helps me.

+2
source share
2 answers

I would choose two solutions for applications. One "real" application that contains all the functionality. The second "key" , which only checks the license.

The first application checks if the key application is installed . If the check is positive, then display the full content, enable all functions. If the key application is missing, the application behaves like a free version.

It is also very important to check whether the private key that signed both applications is the same. Without this check, someone can create their own application. . , : 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 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;
}

:

  • . . . key1 a1, a2, a3 2 b1, b2
  • - . , , . , .
+1

, -

+1

Source: https://habr.com/ru/post/1793563/


All Articles