2

I've been following the developer.android.com page http://developer.android.com/guide/publishing/licensing.html#lc-lcc for directions on using the ServerManagedPolicy type licensing. I've added the Google Market Licensing Package to my application as a library, and I've included this code in my onCreate method:

String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
mChecker = new LicenseChecker(this, new ServerManagedPolicy  this, 
           new AESObfuscator(SALT, getPackageName(), deviceId)),               
           BASE64_PUBLIC_KEY);

At this point I find the instructions confusing. Much of the rest of the sample code on the website appears to be for developing a StrictPolicy or a custom Policy. The example supplied with the library also appears to be for a custom Policy.

How much of the website code is required to use the ServerManagedPolicy library? For example, the library did not come with any resources, yet the website code for doCheck calls a button and text widget. Do i add the doCheck code and make widgets, or is this unnecessary if using the library?

Is there an example of the ServerManagedPolicy library used in an application that does something other than check a license?

Ted Betz
  • 1,621
  • 3
  • 22
  • 29

2 Answers2

4

There is a sample project that shows how to do this in your android sdk folder:

C:\Program Files\Android\android-sdk-windows\extras\google\market_licensing\sample

It shows how to implement the usage of the serverManagedPolicy:

 mChecker = new LicenseChecker(
        this, new ServerManagedPolicy(this,
            new AESObfuscator(SALT, getPackageName(), deviceId)),
        BASE64_PUBLIC_KEY);

You can basically ignore all of the widget calls and modifications in the doCheck() method and focus entirely on the last line, which is:

mChecker.checkAccess(mLicenseCheckerCallback);

This line is what actually fires the LicenseChecker class into action....everything else in the doCheck() method is just for disabling buttons and setting the text on a needless widgets (in your case).

dell116
  • 5,835
  • 9
  • 52
  • 70
1

I had a similar problem earlier.

"Much of the rest of the sample code on the website appears to be for developing a StrictPolicy or a custom Policy" is incorrect assumption..

On the contrary, "rest of the sample code" has nothing to do with "Policy Implementation" {as such} The confusion is because of too much info is packed...

Ignore the Policy part at the beginning. It provides basically back-end to allow user access to app. The Figure 6. is much more comprehensive and overall flow.

Please refer to http://android-codes-examples.blogspot.in/2011/02/android-market-license-verification.html

For complete implementation example... First try the example and then try to understand the purpose of specific components. Google developer source is perhaps the best explanation.

Use the explanation component-wise not as a whole document.

zyndor
  • 1,418
  • 3
  • 20
  • 36
Nik theGeeK
  • 181
  • 12