Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:00:55+00:00 2026-06-02T04:00:55+00:00

I’m attempting to make a free app upgradable to the paid version using in-app

  • 0

I’m attempting to make a free app upgradable to the “paid” version using in-app billing. I used code from this tutorial to handle the billing as the one on the official developer
site is too complex and messy to follow for a simple flow like mine.

My code to do the upgrade works fine.

The problem comes when I try to add something to check if the user has already purchased but has lost their purchase data either by reinstalling or by clearing the data (I don’t care which).

On app startup I check for a flag that’s set after the first run. If that flag isn’t there, the user is shown a dialog warning them that the app will check for previous purchases, and when they click ok, the restoreTransactionInformation method is called. This then causes the application to force close.

Because in-app billing doesn’t work when debugging or on the emulator, I have to publish a signed version of the app each time I want to try the code. I have no way of knowing why the application exits when I try to make the restoreTransactionInformation request. Does anyone have a clue how I can diagnose it, or what might be causing my app to die? Or a working example of how to use the restoreTransactionInformation method?

EDIT: So it looks like the RESTORE_TRANSACTIONS request is getting a correct response, and returning details of my test purchase. Unfortunately before it can do anything with it, the app is forced closed. Here’s a logcat (without obfuscated code) of what happens right after market responds to the RESTORE_TRANSACTIONS request:

I/BillingService( 6484): confirmTransaction()
D/Finsky  ( 1884): [7] MarketBillingService.getPreferredAccount: com.hippypkg: Account from first account.
I/BillingService( 6484): current request is:**********
I/BillingService( 6484): RESTORE_TRANSACTIONS Sync Response code: RESULT_OK
D/WindowManagerImpl( 6484): finishRemoveViewLocked, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@**********
W/InputManagerService( 1381): [unbindCurrentClientLocked] Disable input method client.
W/InputManagerService( 1381): [startInputLocked] Enable input method client.
D/NativeCrypto( 1884): returned from sslSelect() with result 1, error code 2
D/Finsky  ( 1884): [1] MarketBillingService.sendResponseCode: Sending response RESULT_OK for request ********** to com.hippypkg.
I/BillingService( 6484): Received action: com.android.vending.billing.PURCHASE_STATE_CHANGED
I/BillingService( 6484): purchaseStateChanged got signedData: {"nonce":**********,"orders":[{"orderId":"**********","packageName":"com.hippypkg","productId":"hippy_upgrade_free_to_full","purchaseTime":1331476540000,"purchaseState":0}]}
I/BillingService( 6484): purchaseStateChanged got signature: **********==
I/BillingService( 6484): signedData: {"nonce":**********,"orders":[{"orderId":"**********","packageName":"com.hippypkg","productId":"hippy_upgrade_free_to_full","purchaseTime":1331476540000,"purchaseState":0}]}
I/BillingService( 6484): signature: **********==
I/BillingService( 6484): confirmTransaction()
I/BillingService( 6484): makerequestbundle success
I/BillingService( 6484): putstringarray success
D/Finsky  ( 1884): [24] MarketBillingService.getPreferredAccount: com.hippypkg: Account from first account.
D/AndroidRuntime( 6484): Shutting down VM
W/dalvikvm( 6484): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
E/AndroidRuntime( 6484): FATAL EXCEPTION: main
E/AndroidRuntime( 6484): java.lang.RuntimeException: Unable to start receiver com.hippypkg.BillingReceiver: java.lang.NullPointerException
E/AndroidRuntime( 6484):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2144)
E/AndroidRuntime( 6484):    at android.app.ActivityThread.access$2400(ActivityThread.java:135)
E/AndroidRuntime( 6484):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1114)
E/AndroidRuntime( 6484):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 6484):    at android.os.Looper.loop(Looper.java:150)
E/AndroidRuntime( 6484):    at android.app.ActivityThread.main(ActivityThread.java:4385)
E/AndroidRuntime( 6484):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 6484):    at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 6484):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
E/AndroidRuntime( 6484):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
E/AndroidRuntime( 6484):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 6484): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 6484):    at android.os.Parcel.readException(Parcel.java:1328)
E/AndroidRuntime( 6484):    at android.os.Parcel.readException(Parcel.java:1276)
E/AndroidRuntime( 6484):    at com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(IMarketBillingService.java:100)
E/AndroidRuntime( 6484):    at com.hippypkg.BillingHelper.confirmTransaction(BillingHelper.java:152)
E/AndroidRuntime( 6484):    at com.hippypkg.BillingHelper.verifyPurchase(BillingHelper.java:250)
E/AndroidRuntime( 6484):    at com.hippypkg.BillingReceiver.purchaseStateChanged(BillingReceiver.java:41)
E/AndroidRuntime( 6484):    at com.hippypkg.BillingReceiver.onReceive(BillingReceiver.java:23)
E/AndroidRuntime( 6484):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2103)
E/AndroidRuntime( 6484):    ... 10 more
W/ActivityManager( 1381):   Force finishing activity com.hippypkg/.Hippy
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:00:57+00:00Added an answer on June 2, 2026 at 4:00 am

    So I finally managed to figure it out.

    If you look at the Google Docs for the In App Billing Overview, it states that:

    The RESTORE_TRANSACTIONS request type also triggers a PURCHASE_STATE_CHANGED broadcast intent, which contains the same type of transaction information that is sent during a purchase request, although you do not need to respond to this intent with a CONFIRM_NOTIFICATIONS message.

    In a normal purchase-confirmTransaction cycle, when you request to purchase an In App Billing product, google sends back a JSON with a bunch of fields. One of these fields is ‘notification_id’. When google sends a PURCHASE_STATE_CHANGED intent, it expects a CONFIRM_NOTIFICATIONS response from the app, with a bundle containing a bunch of info, including the notification_id’s. All well and good here.

    The problem starts when you get a PURCHASE_STATE_CHANGED from Google for a RESTORE_TRANSACTIONS request from the app. This JSON does not contain notificaion_id fields. The library still responds with a CONFIRM_NOTIFICATIONS, adding the notification_id array to the bundle, which, in this case, is null. That’s what causes the NullPointerException.

    Solution:
    I modified the BillingHelper.java class by adding a boolean to track when the user makes a normal purchase, and when he wants to restoreTransactions.
    If it’s a restoreTransactions request, I send a message back to the handler and skip the confirmNotifications step.

    EDIT:
    The code for the above fix is in BillingHelper.java
    I am using a boolean flag to track whether the user made a RESTORE_TRANSACTIONS call (isRestoreTransactions).

    In BillingHelper.java’s ‘verifyPurchase’ method, I changed the code as follows:

    protected static void verifyPurchase(String signedData, String signature) {
            ArrayList<VerifiedPurchase> purchases = BillingSecurity.verifyPurchase(signedData, signature);
    
            if(isRestoreTransaction)
            {
                /*
                *
                *Add some logic to retrieve the restored purchase product ID's from the 'purchases' array
                *
                */
    
                //Set the boolean to false
                isRestoreTranscation = false;
    
                //Send a message to the handler, informing it that purchases were restored
                if(mCompletedHandler != null){
                    mCompletedHandler.sendEmptyMessage(0);
                } else {
                    Log.e(TAG, "verifyPurchase error. Handler not instantiated. Have you called setCompletedHandler()?");
                }
            }
            else
            {
                /*
                *......
                *......
                *......
                *Original method body here
                *......
                *......
                *......
                */
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.