1

i make android game for Nokia X, Nokia X+, and Nokia XL. i want to add in app purchase to my application. i try many methods but it would not work for me. please see the below code. i call this code from onCreate Method.

    //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);

and code for mServiceConnection is below:

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();
    }
}

}; this code is not working for me. no Toast is showing. so its mean that Service connection is not connected. i give billing permission in manifest. please help me why i am not getting a correct result.

ibad ur rahman
  • 1,381
  • 4
  • 18
  • 40

1 Answers1

1

Are you sure you are running that code in Nokia X emulator or in real device? If payment enabler exists, it should bind to service. If you are running in emulator, please be sure that your AVD target is Nokia X system image (you are able to see nokia style UI).

Br, Janne

jtjk
  • 135
  • 5
  • thanks it work. (AVD target is Nokia X system image (you are able to see nokia style UI).) this thing help me. – ibad ur rahman Apr 04 '14 at 08:18
  • Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), product, ITEM_TYPE_INAPP, "MyPayLoad"); it give response code 5. that mean Invalid arguments provided to the API. please help me. is any problem in arguments. i think problem with "MyPayLoad". – ibad ur rahman Apr 04 '14 at 08:18
  • 1
    MyPayLoad is not the problem. Can you check what is value of *product* there? It should be "com.testapp.sword" or "com.testapp.mighty_sword" or "com.testapp.axe" if you are using product mappings that are visible in your question. – jtjk Apr 04 '14 at 10:11