Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top