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

  • SEARCH
  • Home
  • 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 7842659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:22:23+00:00 2026-06-02T16:22:23+00:00

I am implementing a billing service based on the Dungeons sample (which is the

  • 0

I am implementing a billing service based on the Dungeons sample (which is the way Google recommend you go about it). It’s slightly complicated by the following facts:

  1. The main service class lives in a library project (because I want to reskin the code many times). As this stackoverflow answer suggests a service in a library project may cause problems, I have made the service abstract and inherited it in the sub-projects; this also lets me use different public keys for each reskin (which is desirable).
  2. There are plenty of UI elements that need to know if billing is supported as soon as possible.

Consequently I am calling a function to check if billing is supported from the onCreate() method of the first activity run (actually any activity, but a preference will then be written so this should only happen once).

In the Dungeons sample, the code to check if billing is supported tries to bind to the billing service thus (from the Service class):

boolean bindResult = bindService(
    new Intent(Consts.MARKET_BILLING_SERVICE_ACTION),
    this,  // ServiceConnection.
    Context.BIND_AUTO_CREATE);

this call is throwing a NullPointerException. I’ve checked pretty carefully and none of these things are null; it’s occurring within the function, apparently at line 370 of ContextWrapper.java.

Because of this other stackoverflow answer I wondered if checking billing from onCreate() might be premature but the Dungeons example project, again, calls it from here, so I don’t think it’s this.

I am using a much later version of Android (3.1) so that might have an effect, but I’d love to know the possible causes of this. One other thing: Eclipse is telling me customIntent is null, but it’s not fully clear what that refers to and I’ve not been able to find much about it.

  • 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-02T16:22:24+00:00Added an answer on June 2, 2026 at 4:22 pm

    The answer turns out to be very, very simple: I missed this step in Activity#onCreate:

    mBillingService = new BillingService()
    
    //THIS STEP IS THE CRITICAL STEP
    mBillingService.setContext(this);
    //IF ONLY I HAD KNOWN
    
    mBillingService.checkBillingSupported();
    

    This calls attachBaseContext(context);

    It works now 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in the process of implementing in-app billing and I'm using the Dungeons app
In implementing M-V-VM in a project and following advice of Karl Shifflett about implementing
When implementing the Strategy Pattern, where does one put the code that determines which
When implementing the ISerializable interface in C#, we provide a constructor which takes a
implementing service something similar with tinyurl or bit.ly, I'm would like to expose service
When implementing HTTP services in node.js, there is a lot of sample code like
While implementing the in-app billing for Android application, I came across a problem. Let
Whilst implementing my first MVVM application in WPF, I've been wondering about the pros
I've been working on implementing in-app billing, basing it off of blundell's tutorial here:
Implementing a web service that uses Transport-level security with WCF over HTTP is pretty

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.