When you close the application, you delete all variables, including mIsPremium.
To do this, you need to save the mIsPremium value somewhere and load it when you open the application again.
I suggest you use SharedPreferences for this task.
How could you do this:
In IabHelper.OnIabPurchaseFinishedListener you need to save your preferences:
if (purchase.getSku().equals(PREM_SKU)) { // bought the premium upgrade! Log.d(TAG, "Purchase is premium upgrade. Congratulating user."); alert("Thank you for upgrading to premium!"); mIsPremium = true; mIsUserPremium = true; searchAllowed = true; SharedPreferences prefs = this.getBaseContext().getSharedPreferences( "com.example.yourapp", 0); prefs.edit().putBoolean("premium", true).apply; }
Here you save the state of the premium class "true" for the total premium "premium" after the user has successfully purchased the premium.
In the onCreate () method, you need to load the preference:
SharedPreferences prefs = this.getBaseContext().getSharedPreferences( "com.example.yourapp", 0); mIsPremium = prefs.getBoolean("premium", false);
Here you download the preference "premium", if this preference does not exist yet, it will take the value "false" als by default.
source share