I am trying to implement in-app billing in my application based on Sample Application.
But bindService
always returns false
.
Here is what I have. AndroidManifest.xml:
<service android:name="tv.app.billing.BillingService" />
Preferences.java (need to start purchase from Preferences screen):
protected void onCreate(Bundle savedInstanceState) {
mBillingService = new BillingService();
mBillingService.setContext(this); // tried to use getApplicationContext also
BillingService.java: public class BillingService extends Service implements ServiceConnection {
/**
* Binds to the MarketBillingService and returns true if the bind
* succeeded.
* @return true if the bind succeeded; false otherwise
*/
private boolean bindToMarketBillingService() {
try {
if (Debug.DEBUG) {
Log.i(TAG, "binding to Market billing service");
}
boolean bindResult = bindService(
new Intent(Consts.MARKET_BILLING_SERVICE_ACTION),
this, // ServiceConnection.
Context.BIND_AUTO_CREATE);
if (bindResult) {
return true;
} else {
Log.e(TAG, "Could not bind to service.");
}
} catch (SecurityException e) {
Log.e(TAG, "Security exception: " + e);
}
return false;
}
And in LogCat I see:
WARN/ActivityManager(48): Unable to start service Intent { act=com.android.vending.billing.MarketBillingService.BIND }: not found
What do I need to correct here?
Ok, it can not be tested on the emulator (since it doesn't have Android Market?). Testing In-app Billing section of official site says
You cannot use the Android emulator to test in-app billing
You are right, the billing is not supported by the emulator, but you can use this test framework : android-test-billing to test the In-App billing on the emulator. This framework was used in the project Horer - horaire de RER to simplify the integration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With