Friday, July 29, 2011

Google licensing - the fallout

Did I say I was done with the implementation of Google licensing yesterday? Not quite, it turns out. I had doubts about just checking once, so I put it in to check every time. The problem of course is if you're off the network. First of all, I can check to see if the network is connected, and if not, check a flag. But, working from Panera, it turns I was connected, but Panera's gateway wasn't forwarding my packets, probably because I hadn't clicked "ok" on the login screen. So, this might be a problem for people saving money on phone charges by using free internet at coffee shops.

There's also an issue if you hit "back" on the dialog the tells you you're unlicensed - it takes them right into the program! You need to disable the cancel on the dialog.

Also, just random testing has this one crop up.

E/ActivityThread( 2074): Activity com.myapp.app.StartActivity has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@405abfd0 that was originally bound here
E/ActivityThread( 2074): android.app.ServiceConnectionLeaked: Activity com.jlptquiz.app.StartActivity has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@405abfd0 that was originally bound here


Ok, this could be the problem:

http://developer.android.com/guide/publishing/licensing.html

Failing to call the LicenseChecker's onDestroy() method can lead to problems over the lifecycle of your application. For example, if the user changes screen orientation while a license check is active, the application Context is destroyed. If your application does not properly close the LicenseChecker's IPC connection, your application will crash when the response is received. Similarly, if the user exits your application while a license check is in progress, your application will crash when the response is received, unless it has properly called the LicenseChecker's onDestroy() method to disconnect from the service.

Here's an example from the sample application included in the LVL, where mChecker is the LicenseChecker instance:

@Override
protected void onDestroy() {
super.onDestroy();
mChecker.onDestroy();
...
}


Ok, will, since I'm never leaving the calling activity, it's not getting destroyed. So, I should just call it after the validation is complete.

I'll just at this:

mChecker.onDestroy();


to the allow, dontAllow and applicationError methods of my validating class.

Let's give that another try.

Well, it seems to be working ok. Ok, that's a wrap for now!

No comments:

Post a Comment