Game Development Reference
In-Depth Information
You app needs to have permission to communicate with the Google Play's billing service.
Add this line in the AndroidManifest.xml file.
<uses-permission android :name= "com.android.vending.BILLING" />
Step 3: Binding your activity to the in-app billing service
To set up synchronous communication with Google Play, create an IabHelper instance in
your activity's onCreate method, passing in the Context for the activity and a string con-
taining the public license key.
IabHelper mHelper ;
//Constructs the whole public license key string at runtime
@ Override
public void onCreate(Bundle savedInstanceState) {
// ...
String base64EncodedPublicKey;
// compute your public key and store it in base64EncodedPublicKey
mHelper = new IabHelper( this , base64EncodedPublicKey);
}
//Performs the service binding by calling the startSetup method
//Parameters:
// an OnIabSetupFinishedListene r instance
mHelper.startSetup( new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
//Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
}
});
Once the setup is complete, you can use the mHelper reference to communicate with the
Google Play service. To integrate the Google Play service seamlessly, you need to imple-
ment a few essential methods and interfaces below in your app.
Step 4: Overriding the onActivityResult() method
Search WWH ::




Custom Search