我为诺基亚 X、诺基亚 X+ 和诺基亚 XL 制作安卓游戏。我想在我的应用程序中添加应用程序购买。我尝试了很多方法,但它对我不起作用。请看下面的代码。我从 onCreate 方法调用此代码。
//Verify In-App Payment enabler SHA1 fingerprint.
Intent paymentEnabler = new Intent("com.nokia.payment.iapenabler.InAppBillingService.BIND");
paymentEnabler.setPackage("com.nokia.payment.iapenabler");
bindService(paymentEnabler, mServiceConnection, Context.BIND_AUTO_CREATE);
mServiceConnection 的代码如下:
ServiceConnection mServiceConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
Toast.makeText(getApplicationContext(), "disconnect", Toast.LENGTH_LONG).show();
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = INokiaIAPService.Stub.asInterface(service);
if (isBillingSupported()) {
Bundle productMappings = new Bundle();
productMappings.putString("1023608", "com.testapp.sword");
productMappings.putString("1023609", "com.testapp.mighty_sword");
productMappings.putString("1023610", "com.testapp.axe");
Toast.makeText(getApplicationContext(), "support billing", Toast.LENGTH_LONG).show();
try {
mService.setProductMappings(3, getPackageName(), productMappings);
Toast.makeText(getApplicationContext(), "support billing work", Toast.LENGTH_LONG).show();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
Toast.makeText(getApplicationContext(), "support not billing", Toast.LENGTH_LONG).show();
}
}
}; 这段代码对我不起作用。没有显示 Toast。所以这意味着服务连接没有连接。我在清单中给予计费许可。请帮助我为什么我没有得到正确的结果。