0

For some reason, buyIntentBundle.getParcelable("BUY_INTENT"); is returning null meaning my app ceases to function

Here is the relevant code:

String sku;
public void buyHint(){
    try {
        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(),
                   sku, "inapp", "(id used here)");
        boolean buyintent=false;
        if(buyIntentBundle!=null){
            buyintent=true;
        }
        Log.d("buyintent"+buyintent,"daa");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");


        boolean buyintentparcel=false;
        if(buyIntentBundle.getParcelable("BUY_INTENT")!=null){
            buyintentparcel=true;
        }
        Log.d("buyparcel"+buyintentparcel,"da");
        try {
            startIntentSenderForResult(
                    pendingIntent.getIntentSender(),
                       1131, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));

        } catch (SendIntentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

So pretty much, using my various Log methods, I was able to determine that buyIntent bundle is not null, but buyIntentBundle.getParcelable("BUY_INTENT") is... any ideas

Thank you very much for any help

user3287039
  • 29
  • 1
  • 6

1 Answers1

4

PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); can return NULL if there is no Google account logged in on your Android device.

Maurizio
  • 4,143
  • 1
  • 29
  • 28
  • I took your advice. Tried to run it on my phone instead of an emulator, where I had my Google account logged in, and still received the same error. So, it's got to be something different. Any idea what else it could be? – Peter Griffin Oct 26 '18 at 23:40