1

When trying to query for in-app purchases using getPurchases(), I cannot figure out how to replicate the issue, but sometimes a RemoteException is thrown. I have a try-catch block, but

Bundle ownedItems;
try {
    ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
} catch (RemoteException e) {
    // What do I put here?
}

What causes RemoteException to be thrown, is it preventable? And how can I see what purchases have been made when it's thrown? I need to be able to see what purchases have been made. I have searched but failed to find any details regarding this.

Edit: Here is the stacktrace

Exception android.os.DeadObjectException:
android.os.BinderProxy.transactNative (Binder.java)
android.os.BinderProxy.transact (Binder.java:617)
com.android.vending.billing.IInAppBillingService$Stub$Proxy.getPurchases (IInAppBillingService.java:348)
abraham.johnson.app.MainActivity.isNoAdsPurchased (MainActivity.java:1154)
abraham.johnson.app.MainActivity.access$000 (MainActivity.java:62)
abraham.johnson.app.MainActivity$1.onServiceConnected (MainActivity.java:80)
android.app.LoadedApk$ServiceDispatcher.doConnected (LoadedApk.java:1579)
android.app.LoadedApk$ServiceDispatcher$RunConnection.run (LoadedApk.java:1607)
android.os.Handler.handleCallback (Handler.java:761)
android.os.Handler.dispatchMessage (Handler.java:98)
android.os.Looper.loop (Looper.java:156)
android.app.ActivityThread.main (ActivityThread.java:6523)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:942)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:832)
Trevor
  • 1,349
  • 10
  • 16
  • can you share the stacktrace to better understand what kind of RemoteException? – Pavan Apr 02 '18 at 11:32
  • @Pavan Shared the stacktrace – Trevor Apr 02 '18 at 11:55
  • `DeadObjectException` - The object you are calling has died because its hosting process no longer exists. Can you override `onDestroy` in your `IInAppBillingService` and check if the service still running ? – Pavan Apr 02 '18 at 12:06
  • possibly refer to https://stackoverflow.com/questions/3156389/android-remoteexceptions-and-services – TT-- Dec 13 '18 at 23:39

0 Answers0