开发者

LVL licensing in a Live Wallpaper?

Has anybody had success integrating the Licensing Verification Library (LVL) with a Live Wallpaper? If it were just running an Activity, it'd be crystal clear to ju开发者_开发百科st extend my Activity from the Licensing Activity, which in turn extends Activity. But Live Wallpapers are a Service, and I'm not sure how the two are intended to interact.

I'm using code derived from this: http://www.droidforums.net/forum/android-app-developers/69899-market-license-easy-implementation-protect-your-apps.html which seems to be the code that nearly everything I can find on the web refers to.

I notice that wallpaper settings are an activity, and I have those working properly, but for some reason I can't grok the Licensing stuff...


It's actually really quite simple, you don't need to use any Activity class to implement licensing into a WallpaperService.

Make sure you've followed the directions carefully at http://developer.android.com/guide/publishing/licensing.html

Here's how I did it:

Your extended Engine class should include something similar to the following... (code not essential to your question has been removed)

class startYourEngines extends Engine {     

    public startYourEngines() {
        super();
        licenseStatus(); //custom license check method (for modularity)            
        //the rest of your engine would go here
    }

    public void onDestroy() {
        super.onDestroy();
        licenseChecker.onDestroy(); //we call this to close IPC connections
    }

//prep work
    private static final String BASE64_PUBLIC_KEY = //OMITTED//;
    private LicenseCheckerCallback licenseCallback;
    private LicenseChecker licenseChecker;  
    private byte[] salt = "rAnd0mStr!ng".getBytes();
    private AESObfuscator aes;
    private String deviceId;

//our custom license check method       
    private void licenseStatus() {
        deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
        aes = new AESObfuscator(salt, getPackageName(), deviceId);
        licenseCallback = new licenseVerification();    
        licenseChecker = new LicenseChecker(context, new ServerManagedPolicy(context, aes), BASE64_PUBLIC_KEY);
        licenseChecker.checkAccess(licenseCallback);
    }

//our callback method
    private class licenseVerification implements LicenseCheckerCallback {
        @Override
        public void allow() {
             //allow full app use
        }

        @Override
        public void dontAllow() {
             //prevent or limit app use
        }
        @Override
        public void applicationError(ApplicationErrorCode errorCode) {
             //error handling here
        }

    }
}

Licensing on the Android platform was created with versatility in mind. Just be sure to read through the documentation, and you shouldn't have any issues.


I have only written applications that start activities, but looking at my source code, it seems that the only reason that you would have to have an Activity do the license check is to show dialogs.

In all of the examples available on line, the LicenseCheckerCallback implementation always shows a dialog in the allow() and dontAllow() methods. Why not just show a toast in dontAllow() and exit your wallpaper service (call stopSelf(YourService.this))?

Let me know if you want more information, because I dont think you are limited to only using an activity for license checking. As an aside, make sure that you dont keep whole strings, etc in your app or in the preferences. Anyone with root access can access your preferences and if your app is decompiled, your strings are visible...


I think I've actually got it working now. I'm extending LicenseCheckActivity to my own Activity class that I'm calling in the manifest file with the usual MAIN action and LAUNCH category. I instantiate my class, do the license check, and then either allow the wallpaper to function or not based on that result (though the best way to do that is still something I need to sort out).

It almost seems too easy that I think I must be missing something. I'd appreciate anybody with experience with selling a licensed live wallpaper on the Android Market to share whatever wisdom they care to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜