getParcelable在app billing中返回null

时间:2014-06-21 10:59:47

标签: android null parcelable

出于某种原因,buyIntentBundle.getParcelable(“BUY_INTENT”);返回null意味着我的应用程序停止运行

以下是相关代码:

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();
    }

}

所以,使用我的各种Log方法,我能够确定buyIntent包不是null,但是buyIntentBundle.getParcelable(“BUY_INTENT”)是......任何想法

非常感谢您的帮助

1 个答案:

答案 0 :(得分:2)

如果您的Android设备上没有Google帐户,则

PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");可以返回NULL