wirbly
wirbly

Reputation: 2173

Android Market Licensing: Check during onCreate() or onResume()?

In the included LVL sample app, the license check is triggered during onCreate. This means that when I click "Buy App" to launch the market, then immediately hit the back button to return to the app, the dialog is gone and another check isn't performed, leaving me with a perfectly usable app (at least until the activity is killed and the process starts over again).

Would triggering the license check during onResume() be bad form, even though it would fix this issue? Is there a better solution?

Upvotes: 0

Views: 809

Answers (3)

appFormation
appFormation

Reputation: 253

Wirbly,

Did you put finish(); before or after the intent:

finish();
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
                 "http://market.android.com/details?id=" + getPackageName()));
startActivity(marketIntent); 

or,

Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
                 "http://market.android.com/details?id=" + getPackageName()));
startActivity(marketIntent);
finish();

Thanks.

Upvotes: 0

tcBulldog
tcBulldog

Reputation: 51

Make sure you set the dialog to cancelable(false) or else they can just hit the back button without responding to the dialog choices.

Upvotes: 3

wirbly
wirbly

Reputation: 2173

After further research (and some experience) it appears that using onCreate() to check the license is fine. If you're sticking with the dialog method, adding finish() to the function that goes to the market will ensure that somebody can't just "back" into the app from the market and use it normally. They'll have to re-launch the app, which then triggers the license check again.

Upvotes: 3

Related Questions