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 8515347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:07:21+00:00 2026-06-11T05:07:21+00:00

I’m using AndroidBillingLibrary to implement in-app billing. Purchasing item should disable ads in all

  • 0

I’m using AndroidBillingLibrary to implement in-app billing. Purchasing item should disable ads in all activities. But when I tested my app (at first item was “android.test.purchase” and then real item) happened following: after the purchase ads were disabled, but after restarting the application ads are shown up again.

Item is published in developer’s console, when I purchased item with test account Google Play said that all is Ok.

Purchase button is located in the settings of my application. Here is part of the code:

public class PreferencesActivity extends SherlockPreferenceActivity { 
    public final static String PUBLIC_KEY = "my public key";
    public final static String ANDROID_ADS_ITEM = "ads.buy"; 
    private AbstractBillingObserver billingObserver;

    ...

    @Override protected void onDestroy(){   
        BillingController.unregisterObserver(billingObserver);  
        super.onDestroy(); 
    }

    private void adsDisable(){  
        final Preference adsDisable = (Preference) findPreference("disableAds");
        billingObserver = new AbstractBillingObserver(this){    
            public void onRequestPurchaseResponse(String itemId, ResponseCode response){ 
            }

            public void onPurchaseStateChanged(String itemId, PurchaseState state){
            }

            public void onBillingChecked(boolean supported){
                if(!supported)
                    adsDisable.setEnabled(false);
                else if(!billingObserver.isTransactionsRestored())
                    BillingController.restoreTransactions(PreferencesActivity.this); 
            }

            public void onSubscriptionChecked(boolean supported) {
                // TODO Auto-generated method stub
            }       
        };

        BillingController.setConfiguration(new IConfiguration(){

            public String getPublicKey(){
                return PUBLIC_KEY;          
            }

            public byte[] getObfuscationSalt(){
                return new byte[]{ 41, -90, -116, -41, 66, -53, 122, -110, -127, -96, -88, 77, 127, 115, 1, 73, 57, 110, 48, -116 }; 
            }

        }); 

        BillingController.registerObserver(billingObserver);        
        BillingController.checkBillingSupported(this);

        adsDisable.setOnPreferenceClickListener(new OnPreferenceClickListener(){ 
            public boolean onPreferenceClick(Preference preference){
                BillingController.requestPurchase(PreferencesActivity.this, ANDROID_ADS_ITEM, true, null);
                return false;
            }
        });

        boolean purchased = BillingController.isPurchased(this, ANDROID_ADS_ITEM);
        if(purchased){ 
            adsDisable.setTitle(R.string.disableAdsYes_prefs);          adsDisable.setEnabled(false);
        }
    }

And this is how I try to disable ads:

public class FirstActivity extends SherlockActivity {
    public final static String ANDROID_ADS_ITEM = "ads.buy";
    private AdView adView;
    LinearLayout layout;

    @Override
    public void onCreate(Bundle savedInstanceState) {
       ...
        String adId = "my ad id";

        boolean purchased = BillingController.isPurchased(this, ANDROID_ADS_ITEM);
        if(purchased){
             layout = (LinearLayout) findViewById(R.id.ads);
            layout.removeView(layout);
        } else {
        adView = new AdView(this, AdSize.BANNER, adId);
        layout = (LinearLayout) findViewById(R.id.ads);
        layout.addView(adView);
        AdRequest adRequest = new AdRequest();
        adView.loadAd(adRequest);
       }
    }
  ....
}

Please, help. And sorry for my English.

  • 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-11T05:07:23+00:00Added an answer on June 11, 2026 at 5:07 am

    Most likely the problem is that you’re initialising the library configuration (public key and salt) in your preference activity. This means that the library will not be properly configured until you open preferences. Quoting the README:

    Additionally, BillingController requires a
    BillingController.IConfiguration instance from which the public key
    required to validate signed messages and a salt to obfuscate
    transactions are obtained. A good place to provide the configuration
    is in the Application subclass.

    In this case, when you’re calling isPurcharsed in your FirstActivity the billing controller doesn’t have a salt to unobfuscate the database.

    Check out DungeonsRedux for an example of setting the configuration in the Application subclass.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

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.