I have many problems integrating Google In-App-Billing.
I have an activity that In-App-Billing should do. I call this action from my main action using the startActivity method.
Intent i = new Intent(); i.setComponent(new ComponentName("com.mypackage.mainactivity","com.mypackage.mainactivity.InAppBillingActivity")); startActivity(i);
and calling mBillingService.requestPurchase("android.test.purchased", "10") in the onCreate method for In-App-Billing activity.
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); mInAppBillingPurchaseObserver = new InAppBillingPurchaseObserver(mHandler); mBillingService = new BillingService(); mBillingService.setContext(this); ResponseHandler.register(mInAppBillingPurchaseObserver); boolean supported = mBillingService.checkBillingSupported(); System.out.println("onCreate.isBillingSupported " + supported); if(supported) { Log.i("AJ", "Calling requestPurchase"); mBillingService.requestPurchase("android.test.purchased", "10"); } }
Since In-App-Billing makes an asynchronous call to the server, when I have to call finish () to return to the main action. But I do not want the activity to end, I still need the results of an asynchronous call. So how can I handle this.
I called the finish line () after sending a request to the server. But then I got this exception:
05-29 03:11:58.897: ERROR/ActivityThread(3549): Activity com.mypackage.mainactivity.InAppBillingActivity has leaked ServiceConnection com.mypackage.mainactivity.BillingService@45b0ad50 that was originally bound here 05-29 03:11:58.897: ERROR/ActivityThread(3549): android.app.ServiceConnectionLeaked: Activity com.mypackage.mainactivity.InAppBillingActivity has leaked ServiceConnection com.mypackage.mainactivity.BillingService@45b0ad50 that was originally bound here 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ActivityThread$PackageInfo$ServiceDispatcher.(ActivityThread.java:1158) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ActivityThread$PackageInfo.getServiceDispatcher(ActivityThread.java:1053) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ContextImpl.bindService(ContextImpl.java:908) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.content.ContextWrapper.bindService(ContextWrapper.java:347) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.content.ContextWrapper.bindService(ContextWrapper.java:347) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at com.mypackage.mainactivity.BillingService.bindToMarketBillingService(Unknown Source) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at com.mypackage.mainactivity.BillingService.access$000(Unknown Source) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at com.mypackage.mainactivity.BillingService$BillingRequest.runRequest(Unknown Source) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at com.mypackage.mainactivity.BillingService.checkBillingSupported(Unknown Source) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at com.mypackage.mainactivity.InAppBillingActivity.onCreate(Unknown Source) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2701) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2753) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ActivityThread.access$2500(ActivityThread.java:129) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2107) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.os.Handler.dispatchMessage(Handler.java:99) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.os.Looper.loop(Looper.java:143) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at android.app.ActivityThread.main(ActivityThread.java:4701) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at java.lang.reflect.Method.invokeNative(Native Method) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at java.lang.reflect.Method.invoke(Method.java:521) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-29 03:11:58.897: ERROR/ActivityThread(3549): at dalvik.system.NativeStart.main(Native Method)
He did not exit the application, but stopped InAppBillingActivity.
Any help is most appreciated.
Thanks Akash
PS: My old question is still not resolved .....
AkasH source share