I am trying to use
BillingDataSource.java
Security.java
from TrivialDriveSample I managed to get the purchase for a Premium SKU (one time purchase) but where can I check if this product is bought when my App start in order to unlock features each time the App starts I need to call from my MainActivity a method to see if it is ok
if I ask
@Override
public void onResume() {
super.onResume();
LiveData<Boolean> IsPremiumPurchased = ((MainActivity)getActivity()).billingDataSource.isPurchased(SKU_PREMIUM);
mIsPremium = IsPremiumPurchased.getValue();
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
((MainActivity)getActivity()).updateUi();
}
I got Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference at com.xxxxxxxxxxx.MainActivity$MainFragment.onResume(MainActivity.java:1302)
because IsPremiumPurchased is not valid