Skip to content

vanleeuwenbram/AndroidBillingLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Android Billing Library

requestPurchase("com.example.item")

That's how simple it should be to use Android In-app Billing.

And with this library it is.

(or will be; this is a very early release)

Android Billing Library implements in-app billing's full specification and offers high-level classes to use it. Transactions are stored in a local obfuscated database which can be easily queried.

Getting Started

  • Add this library to your project.

  • Open the AndroidManifest.xml of your application and add this permission...

<uses-permission android:name="com.android.vending.BILLING" />

...and this service and receiver inside the application element:

<service android:name="net.robotmedia.billing.BillingService" />
<receiver android:name="net.robotmedia.billing.BillingReceiver">
	<intent-filter>
		<action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
		<action android:name="com.android.vending.billing.RESPONSE_CODE" />
		<action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
	</intent-filter>
</receiver>

That's it!

Usage

Subclassing AbstractBillingActivity

AbstractBillingActivity is an abstract activity that provides default integration with in-app billing. It is useful to get acquainted with the library, or for very simple applications. For more flexibility use BillingController instead.

When started your AbstractBillingActivity subclass will check if in-app billing is supported, followed by a call to onBillingChecked(boolean), which has to be implemented by the subclass.

Additionally, the first your AbstractBillingActivity subclass runs it will attempt to restore all transactions. This is necessary in case the user has previously installed the app and made purchases. Existing transactions will generate calls to onPurchaseExecuted(String), onPurchaseCancelled(String) and onPurchaseRefunded(String) accordingly, all of which have to be implemented by the subclass.

Starting a purchase is as simple as calling requestPurchase(String). AbstractBillingActivity will start the Android Market intent automatically and onPurchase{State}(String) will be called after the transaction is confirmed.

BillingController

BillingController provides high-level functions to interact with the Billing service and to query an obfuscated local transaction database.

Since most billing functions are asynchronous, BillingController notifies all registered IBillingObserver of the responses. 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.

Disclaimer

This library is a very early release and it should not be used as production code.

Contact

http://www.twitter.com/robot_media | http://www.facebook.com/robotmedia | http://www.robotmedia.net

License

Copyright 2011 Robot Media SL. All rights reserved.

Android Billing Library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Android Billing Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser Public License for more details.

You should have received a copy of the GNU Lesser Public License along with Android Billing Library. If not, see http://www.gnu.org/licenses/.

About

Android Market In-app Billing Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published