Skip to content Skip to sidebar Skip to footer

Why Am I Getting A Null Pointer Error In My Android Code?

I am getting a null point error in my code and the log is pointing here 199 public void getPurchasedSubs () throws RemoteException { 200 Bundle ownedItems = mService.ge

Solution 1:

I think you use mService before connect to service.

My suggestion is to use boolean variable to check if activity connect to service or not, or use getPurchasedSubs () in onServiceConnected like this:

ServiceConnection mServiceConn = newServiceConnection() {
   publicvoidonServiceDisconnected(ComponentName name) {
       mService = null;
   }

   publicvoidonServiceConnected(ComponentName name, 
      IBinder service) {
       mService = IInAppBillingService.Stub.asInterface(service);
getPurchasedSubs ();
   }

};  

hope this helped you.

Post a Comment for "Why Am I Getting A Null Pointer Error In My Android Code?"