• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Fun with LVL (license verification library)

RLScott

Newbie
Nov 4, 2015
26
4
I think I am having success so far integrating license checking in my app. I have mostly followed the recommended use of a ServerManagedPolicy. It is neat that when you download the LVL and integrate it into your app, you get a copy of the source that you can easily customize, and I have.

My customized ServerManagedPolicy maintains a new variable called mLastDefinitiveResponse, similar to the existing mLastResponse. The difference is that mLastDefinitiveResponse is set to either LICENSED or NOT_LICENSED when either of these responses are returned from the market server. It is unchanged when any other response is received. So when a license check is done in my application and my callback's "dontAllow" method is called, I can query mLastDefinitiveResponse (available through a public getter that I added to ServerManagedPolicy) to see what the last definitive response was. If that response was LICENSED I want to allow the user to continue to use my app regardless of any retry timeouts. My reason is that my app is a utility that might be used almost all the time in places and on devices were there is no network connection. (Don't ask. It's a niche app.) So my licensing policy is more liberal than the standard ServerManagedPolicy, and I am OK with that.

When I get a "dontAllow" callback and the last definitive response was NOT_LICENSED, I throw up an AlertDialog telling the user I am switching to the play store, and then I call mChecker.followLastLicensingURL() where mChecker is my LicenseChecker object. And it works. Since the app is still in development, the responses from the Google Play Store are static and set by me in the developer console. And that is working fine too. (There is a delay of up to several hours between when I change the static response and when that new response is returned by my licensing query.) But here is my question. When followLastLicensingURL() takes me to Google Play, it shows my app with buttons for "UNINSTALL" and "OPEN". I guess that is because that is what the Play Store shows when you go to an app that is already installed. But if I really were running a bootleg copy of my app, would the Play Store give me the option of purchasing the app at this point? I really don't know how to test that until I actually release a production version of my app.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones