this library is a small helper with a simple API that makes it very easy to communicate with IranApps in-app billing service.
in the project there's also a sample of how to use the helper.
you can find IranApps in-app billing documentation here
the library is uploaded to jCenter and you can see it below:
Easily reference the library in your Android projects using this dependency in your module's build.gradle
file:
dependencies {
compile 'ir.tgbs.iranapps:billing-helper:2.0'
}
to use this library in your eclpise projects to the following:
- download the library's jar file from jCenter at here
- add the jar as a library to your project.
- download IranApps in-app billing aidl file from here
- put the downloaded aidl file in
src/ir/tgbs/iranapps/billing
- add IranApps billing permission to your manifest
<uses-permission android:name="ir.tgbs.iranapps.permission.BILLING"/>
- your ready to go, Enjoy
- in the activity that you want to do in-app billing requests create a new instance of
InAppHelper
insideonCreate
.
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.activity_main);
inAppHelper = new InAppHelper(this, new InAppHelper.InAppHelperListener() {
@Override
public void onConnectedToIABService() {
}
@Override
public void onCantConnectToIABService(InAppError inAppError) {
}
@Override
public void onConnectionLost() {
}
});
}
- Override
onDestroy
in that activity and callonActivityDestroy
inInAppHelper
@Override
protected void onDestroy() {
super.onDestroy();
inAppHelper.onActivityDestroy();
}
- Override
onActivityResult
in that activity and callonActivityResult
inInAppHelper
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
inAppHelper.onActivityResult(requestCode, resultCode, data);
}
if your activity is able to be destroyed and recreated you must save and restore the InAppHelper of that activity and update the listener of any operation that is currently in progress. for an example you can see the BaseInAppActivity and the implementation of 'InAppHolderFragment' that saves the data and can be retained in activity's onCreate method(also see the onCreate() method inside BaseInAppActivity on how the InAppHelper instance is created). and see BuyActivity on how the buy product operation's listener is updated inside onCreate() method.
if your using proguard in your app add this line to you proguard-rules.pro file
-keep class ir.tgbs.iranapps.billing.IranAppsIabService
this project is based on Android Studio.
to localy run the sample you need to do the following:
- download the project from here
- extract the project zip
- from Android studio go to File->import project and select the folder of extracted files
- now run the sample module.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
TODO: Write credits
TODO: Write license