So I’m trying to properly implement licensing into my live wallpaper. All the code is in there, everything compiles, but the stopSelf() method of my WallpaperService just doesn’t seem to be working. Here is what I have:
public class MyWallpaperService extends WallpaperService implements LicenseCheckerCallback{
...
@Override
public void onCreate() {
super.onCreate();
String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
// Construct the LicenseChecker with a Policy.
mChecker = new LicenseChecker(
this, new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY // Your public licensing key.
);
mChecker.checkAccess(this);
}
@Override
public void onDestroy() {
super.onDestroy();
mChecker.onDestroy();
//Log.d(DEB_TAG, "onDestroy()");
}
@Override
public Engine onCreateEngine() {
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS_NAME,0);
return new MyEngine(prefs);
}
public void allow(int reason) {
}
public void dontAllow(int reason) {
Toast.makeText(getApplicationContext(), "This application is not licensed on this device", Toast.LENGTH_SHORT).show();
stopSelf();
}
public void applicationError(int errorCode) {
}
...
}
It’s driving me up the wall. The dontAllow() method is definitely getting called, because I see the Toast pop up, but the WallpaperService carries merrily on running, and I can’t find a good reason why that might be. Does anyone have any ideas?
Personally I just cripple my draw function with a boolean. This will leave the live wallpaper up, but not update it. It essentially becomes an image.