我试图在基于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