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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:36:15+00:00 2026-06-06T11:36:15+00:00

I set up the Dungeons InAppBilling example locally and I am ready to try

  • 0

I set up the “Dungeons” InAppBilling example locally and I am ready to try it out, but I am a bit confused. I have a button like this:

Button donate = (Button)findViewById(R.id.donate);     
donate.setOnClickListener(new Button.OnClickListener() {  
        public void onClick(View v) {     
        // But what do I do here? :)
        }
});

And when it is called, what do I need to do to actually go to the pay screen on android store?

Thanks!

  • 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-06T11:36:16+00:00Added an answer on June 6, 2026 at 11:36 am

    1)download

    http://developer.android.com/guide/google/play/billing/billing_integrate.html#billing-download

    2)add

    http://developer.android.com/guide/google/play/billing/billing_integrate.html#billing-add-aidl

    3)add permission in your android manifest file

    http://developer.android.com/guide/google/play/billing/billing_integrate.html#billing-permission

    now your project should look like this…

    enter image description here

    4) place the public key (you can find it in developer console in the
    bottom section of edit profile) in the Security.java in line saying
    String base64EncodedPublicKey = “your public key here”

    5) and finally your activity which have button should be look like this

    public class YourActivity extends Activity implements OnClickListener {
    String issueProductId = “Your Product ID”;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.updates);
        SetInAppBilling();
        Button donate = (Button) findViewById(R.id.donate);
        donate.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                if (mBillingService.requestPurchase(issueProductId, null)) {
    
                } else {
                    showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
                    Log.i("tag", "Can't purchase on this device");
    
                }
    
            }
        });
    }
    
    
    public void register() {
        ResponseHandler.register(mDungeonsPurchaseObserver);
    }
    
    public void unregister() {
        ResponseHandler.unregister(mDungeonsPurchaseObserver);
    }
    
    public void close_unbind() {
        if (mPurchaseDatabase != null)
            // mPurchaseDatabase.close();
            if (mBillingService != null)
                mBillingService.unbind();
        // stopService(new Intent(this, BillingService.class));
    }
    
    /**
     * Called when this activity becomes visible.
     */
    @Override
    protected void onStart() {
        super.onStart();
    
        register();
    }
    
    /**
     * Called when this activity is no longer visible.
     */
    @Override
    protected void onStop() {
        unregister();
        super.onStop();
    
    }
    
    @Override
    protected void onDestroy() {
        close_unbind();
        super.onDestroy();
    
    }
    
    private static final String TAG = "YourActivity";
    
    private static final String DB_INITIALIZED = "db_initialized";
    
    // private static final String Dir_Check = "Dir_Check";
    
    private DungeonsPurchaseObserver mDungeonsPurchaseObserver;
    private Handler mHandler;
    
    private BillingService mBillingService;
    private PurchaseDatabase mPurchaseDatabase;
    private static final int DIALOG_CANNOT_CONNECT_ID = 1;
    private static final int DIALOG_BILLING_NOT_SUPPORTED_ID = 2;
    private Cursor mOwnedItemsCursor;
    
    public void SetInAppBilling() {
        mHandler = new Handler();
        mDungeonsPurchaseObserver = new DungeonsPurchaseObserver(mHandler);
        mBillingService = new BillingService();
        mBillingService.setContext(this);
    
        mPurchaseDatabase = new PurchaseDatabase(this);
    
        mOwnedItemsCursor = mPurchaseDatabase
                .queryAllPurchasedHistroyTabelItems();
        startManagingCursor(mOwnedItemsCursor);
    
        SharedPreferences prefs = getPreferences(MODE_PRIVATE);
        boolean initialized = prefs.getBoolean(DB_INITIALIZED, false);
        // Check if billing is supported.
        ResponseHandler.register(mDungeonsPurchaseObserver);
        if (!mBillingService.checkBillingSupported()) {
            showDialog(DIALOG_CANNOT_CONNECT_ID);
        }
    }
    
    private class DungeonsPurchaseObserver extends PurchaseObserver {
        public DungeonsPurchaseObserver(Handler handler) {
            super(YourActiviy.this, handler);
        }
    
        @Override
        public void onBillingSupported(boolean supported) {
    
            Log.i(TAG, "supportedCheck: " + supported);
            if (Consts.DEBUG) {
                Log.i(TAG, "supported: " + supported);
            }
            if (supported) {
                restoreDatabase();
            } else {
                showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
            }
        }
    
        @Override
        public void onPurchaseStateChange(PurchaseState purchaseState,
                String itemId, int quantity, long purchaseTime,
                String developerPayload) {
            if (Consts.DEBUG) {
                Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " "
                        + purchaseState);
            }
    
            if (developerPayload == null) {
    
            } else {
    
            }
    
            Log.e(TAG, "onPurchaseStateChangeCheck: " + "onPurchaseStateChange");
            if (purchaseState == PurchaseState.PURCHASED) {
    
                /** TODO: */
                Toast.makeText(
                        mContext,
                        "You successfully upgraded to the entire Volume One. Enjoy!",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
    
        }
    
        @Override
        public void onRequestPurchaseResponse(RequestPurchase request,
                ResponseCode responseCode) {
            if (Consts.DEBUG) {
                Log.d(TAG, request.mProductId + ": " + responseCode);
            }
            if (responseCode == ResponseCode.RESULT_OK) {
                if (Consts.DEBUG) {
                    Log.i(TAG, "purchase was successfully sent to server");
                }
    
            } else if (responseCode == ResponseCode.RESULT_USER_CANCELED) {
                if (Consts.DEBUG) {
                    Log.i(TAG, "user canceled purchase");
                }
    
            } else {
                if (Consts.DEBUG) {
                    Log.i(TAG, "purchase failed");
                }
    
            }
        }
    
        @Override
        public void onRestoreTransactionsResponse(RestoreTransactions request,
                ResponseCode responseCode) {
            if (responseCode == ResponseCode.RESULT_OK) {
                if (Consts.DEBUG) {
                    Log.d(TAG, "completed RestoreTransactions request");
                }
                // Update the shared preferences so that we don't perform
                // a RestoreTransactions again.
    
                SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);
                SharedPreferences.Editor edit = prefs.edit();
                edit.putBoolean(DB_INITIALIZED, true);
                edit.commit();
    
                mOwnedItemsCursor = mPurchaseDatabase
                        .queryAllPurchasedHistroyTabelItems();
                Log.d(TAG, String.valueOf(mOwnedItemsCursor.getCount()));
                startManagingCursor(mOwnedItemsCursor);
    
                if (mOwnedItemsCursor.getCount() > 0) {
                    Log.d(TAG, "Updating the DB");
                    Toast.makeText(
                            mContext,
                            "You successfully upgraded to the entire Volume One. Enjoy!",
                            Toast.LENGTH_SHORT).show();
                    finish();
                }
    
            } else {
                if (Consts.DEBUG) {
                    Log.d(TAG, "RestoreTransactions error: " + responseCode);
                }
            }
        }
    }
    
    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DIALOG_CANNOT_CONNECT_ID:
            return createDialog(R.string.cannot_connect_title,
                    R.string.cannot_connect_message);
        case DIALOG_BILLING_NOT_SUPPORTED_ID:
            return createDialog(R.string.billing_not_supported_title,
                    R.string.billing_not_supported_message);
        default:
            return null;
        }
    }
    
    private Dialog createDialog(int titleId, int messageId) {
        String helpUrl = replaceLanguageAndRegion(getString(R.string.help_url));
        if (Consts.DEBUG) {
            Log.i(TAG, helpUrl);
        }
        final Uri helpUri = Uri.parse(helpUrl);
    
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(titleId)
                .setIcon(android.R.drawable.stat_sys_warning)
                .setMessage(messageId)
                .setCancelable(false)
                .setPositiveButton(android.R.string.ok, null)
                .setNegativeButton(R.string.learn_more,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int which) {
                                Intent intent = new Intent(Intent.ACTION_VIEW,
                                        helpUri);
                                startActivity(intent);
                            }
                        });
        return builder.create();
    }
    
    /**
     * Replaces the language and/or country of the device into the given string.
     * The pattern "%lang%" will be replaced by the device's language code and
     * the pattern "%region%" will be replaced with the device's country code.
     * 
     * @param str
     *            the string to replace the language/country within
     * @return a string containing the local language and region codes
     */
    private String replaceLanguageAndRegion(String str) {
        // Substitute language and or region if present in string
        if (str.contains("%lang%") || str.contains("%region%")) {
            Locale locale = Locale.getDefault();
            str = str.replace("%lang%", locale.getLanguage().toLowerCase());
            str = str.replace("%region%", locale.getCountry().toLowerCase());
        }
        return str;
    }
    
    private void restoreDatabase() {
        SharedPreferences prefs = getPreferences(MODE_PRIVATE);
        boolean initialized = prefs.getBoolean(DB_INITIALIZED, false);
        if (!initialized) {
            mBillingService.restoreTransactions();
            // Toast.makeText(this, "restoring...", Toast.LENGTH_LONG).show();
    
        }
    }
    

    }

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

Sidebar

Related Questions

i have a mysql table set up like so: id uid keywords -- ---
I set an images for button's states Normal,Highlighted and Selected, but when the button
set(TestProject_additional_libs optimized foobar.lib debug foobard.lib } especially what is optimized/debug mean here? Is this
Set content of table ... ViewState[Table1] = Table1; // When remove this line, table
SET @v1 := SELECT COUNT(*) FROM user_rating; SELECT @v1 When I execute this query
set JAVA_OPTS=-Xms256m -Xmx512m -Djava.awt.headless=true -XX:MaxPermSize=256m -server This argument works in run.bat of jboss but
set A=2 && echo %A% This does not echo A as 2 in windows.
SET SS_SOURCE_PROJECT = sausages @echo SS_SOURCE_PROJECT = %SS_SOURCE_PROJECT% This isn't working, it just outputs:
set phoneNumber 1234567890 this number single digit, i want divide this number into 123
std::set<std::string> setStrings; setString.insert(abc); setString.insert(abcd); setString.insert(babc); Question> I would like to know how to check

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.