I've tried to use the new license service of Android and I am facing some troubles. My code in the main activity looks like this:
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
String deviceId = Secure.getString(MainTabActivity.this.getContentResolver(), Secure.ANDROID_ID);
mChecker = new LicenseChecker(
MainTabActivity.this, new ServerManagedPolicy(MainTabActivity.this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY
);
mChecker.checkAccess(mLicenseCheckerCallback);
(basically just the shown code of the Android online documentation. The callback passes through if it's allowed and if it's not it displays a message and quits the app. So far so good.
The problem is that it works fine in the debugger, but when I publish it to the market and upgrade my app (I've purchased a version of my app with my personal gmail-accout, so I am a legiti开发者_如何学Pythonmate user) I get the error that the my app is not licensed. I've even added my personal gmail address to the whitelist in my market-profile and set the status to "LICENSED" but it still comes up with the error. Do you have any suggestions ?
The callback from the licensing service sometimes doesn't happen for several seconds - worse if there is network lag. It will generally cache the answer in the service after a successful attempt to help reduce that lag on later app starts.
You most likely need to move the logic for closing the app (or disabling features) to later in the UI experience.
I've also had a few false negatives for users that were corrected if they closed the app and tried again later.
I had the same issue and added
<uses-permission
android:name="com.android.vending.CHECK_LICENSE"></uses-permission>
to the manifest, did the trick for me!
精彩评论