我試圖在基於Sample Application的應用中實施應用內結算。 但是bindService
總是返回false
。Android的應用內結算和bindService
這是我的。 AndroidManifest.xml中:
<service android:name="tv.app.billing.BillingService" />
Preferences.java(需要開始從首屏購買):
protected void onCreate(Bundle savedInstanceState) {
mBillingService = new BillingService();
mBillingService.setContext(this); // tried to use getApplicationContext also
BillingService.java: 公共類BillingService有擴展服務實現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;
}
而在logcat中我看到:
WARN/ActivityManager(48): Unable to start service Intent { act=com.android.vending.billing.MarketBillingService.BIND }: not found
什麼我需要在這裏糾正?
奇怪,但它並不只在模擬器上工作和實際工作的設備上。可能,我應該等待服務啓動? – 2011-04-09 17:04:35