Note that there are some explanatory texts on larger screens.

plurals
  1. POInAppBilling activity and finish()
    primarykey
    data
    text
    <p>I'm having lots of trouble with integrating google's In-App-Billing. </p> <p>I have an activity which is supposed to do the In-App-Billing. I'm calling this activity from my main activity using the startActivity method.</p> <pre><code> Intent i = new Intent(); i.setComponent(new ComponentName("com.mypackage.mainactivity","com.mypackage.mainactivity.InAppBillingActivity")); startActivity(i); </code></pre> <p>and calling <code>mBillingService.requestPurchase("android.test.purchased", "10")</code> in the onCreate method on In-App-Billing activity.</p> <pre><code> 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"); } } </code></pre> <p>Since In-App-Billing makes an asynchronous call to the server, when should i call finish() to return to the main activity. But i dont want the activity to end, i still need the results of the async call made. So how do i go about handling that.</p> <p>I called the finish() after sending the request to the server. But then i got this exception : </p> <pre><code> 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) </code></pre> <p>It didn't exit the application, but it stopped the InAppBillingActivity.</p> <p>Any help is most appreciated. </p> <p>Thanks, AkasH</p> <p>P.S.: <a href="https://stackoverflow.com/questions/5429345/google-inappbilling-onpurchasestatechange-is-never-called">My Old Question</a>, still unsolved..... </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload