Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck PhoneGap Android app LVL license, using in async thread
    primarykey
    data
    text
    <p>I want to know how I can fire Android's LVL license verification in an asynchronous thread while my Phonegap app starts loading. If the verification results in a "no access" I want the app to close. I prefer this logic to the usual one-step-at-a-time setup. LVL takes quite a few seconds, and if an evil unlicensed user gets to see the app for a few seconds before it's closed, that is not a problem.</p> <p><strong>The problem</strong> is that I'm not big on Java. </p> <p><strong>My app</strong> I've got a PhoneGap (Cordova) paid app published in Google Play's that uses LVL Verification to check the app was paid for by the user. Working like a charm, except that the check takes about five seconds. Often, even the splash screen does not show for a few seconds, seemingly because of this.</p> <p>So the user is stuck with a black screen for five seconds, and <em>then</em> gets the splash screen while the Java code is being loaded, and finally they get to see a default dimmed home screen until the Java<em>script</em> is done. So I'm highly motivated to reduce this startup delay.</p> <p>I've read a <a href="https://stackoverflow.com/questions/7136786/android-lvl-licensing-service-is-incredibly-slow-solutions-async">few comments</a> that suggest using an asynchronous approach: start loading the URL right away, and run the license check as an asyncTask. But I don't know how to pass the webview to the asyncTask in order for the webview to be closed if the license is not valid.</p> <p><strong>My first try</strong> Since the license check itself is an async process, I've tried to first set the splash screen and load the URL, then do the license check. See code below. If the check returns 'not allowed', the callback should close the app. However, if I try this setup, somehow the LVL server <em>always</em> returns "valid", even if I set a forced response to 'invalid' or 'unknown' or anything else on Google Play.</p> <p>I'm looking for either A or B: A. A way to get LVL to respond correctly. B. Another way to implement an async license check.</p> <p><strong>The code</strong> Below is an abstraction of the current code. DroidGap is the webview. Basically, onCreate kicks off the license check, and the license check callback either loads the app's HTML or closes the webview.</p> <pre><code>public class App extends DroidGap { public void onCreate(Bundle icicle) { super.setIntegerProperty("splashscreen", R.drawable.splash); super.loadUrl("file:///android_asset/www/index.html"); mCheckerCallback = new LicenseCheckerCallback(); checkAccess(mCheckerCallback); } private class MyCheckerCallback implements LicenseCheckerCallback() { public void Allow() { //Do nothing } public void DontAllow(){ finish(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload