Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
Contributor
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book
My Carrier: Airtel

Re: Android - Inapp purchase sending request fails.

Thanks for all your help,

 

After resetting the device and changing the Blackberry id its working fine now.

 

But just before some time it started saying "RESULT_SERVICE_UNAVAIABLE" .

 

What might be the issue?

New Contributor
Posts: 6
Registered: ‎09-19-2013
My Device: Playbook
My Carrier: Virgin

Re: Android - Inapp purchase sending request fails.

After a lot of work, I found the solution myself a few months ago, which I posted here:

http://supportforums.blackberry.com/t5/Android-Runtime-Development/Is-in-app-billing-API-v3-supporte...

Basically, in the BillingService class, in the BillingRequest.makeRequestBundle, change:

request.putInt(Consts.BILLING_REQUEST_API_VERSION, 2);
to
request.putInt(Consts.BILLING_REQUEST_API_VERSION, 1);

 

For crashing:

Add a null check to the intent arg in the billing service's onStart method.

For RESULT_SERVICE_UNAVAIABLE, I got that occasionally but figured it was a WiFi / connection issue.

Contributor
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book
My Carrier: Airtel

Re: Android - Inapp purchase sending request fails.

hello rockgecko ,

 

 Thanks for your reply.

 

I did not get your point ?

 

What do i need to do in this method ?

@Override
    public void onStart(Intent intent, int startId) {
	handleCommand(intent, startId);
    }

 

And also i have two buttons, buy and restore button in my app, now on click of BUY button it will initiate the purchase request and user will buy the app and he will uninstall the app,now again when he installs the app, he has already purchased it and he will click on RESTORE button, now which method should i invoke in Dungeons example?

 

New Contributor
Posts: 6
Registered: ‎09-19-2013
My Device: Playbook
My Carrier: Virgin

Re: Android - Inapp purchase sending request fails.

Android services can be restarted with a null argument for the intent, as per the documentation: http://developer.android.com/reference/android/app/Service.html#onStartCommand(android.content.Inten... int, int)

Dungeons restores transactions on first start, or if it has not yet restored them successfully after an install. Call RESTORE_TRANSACTIONS. PURCHASE_STATE_CHANGED then happens sometime later for each purchased item, as per the docs: http://developer.android.com/google/play/billing/v2/api.html
Contributor
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book
My Carrier: Airtel

Re: Android - Inapp purchase sending request fails.

[ Edited ]

 

So you mean to say:

 

Instead on this :

 

@Override
public void onStart(Intent intent, int startId) {
    handleCommand(intent);
}

 It should be like this ?

 

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    handleCommand(intent);
    // We want this service to continue running until it is explicitly
    // stopped, so return sticky.
    return START_STICKY;
}

 Please correct me if i am wrong with th above code.

 

Regarding the RESTORE_TRANSACTIONS:

 

This gets called, But when does this gets called? on which method do i need to invoke.

 

@Override
	public void onPurchaseStateChange(PurchaseState purchaseState, String itemId, int quantity, long purchaseTime, String developerPayload) {
	    if (Consts.DEBUG) {
		Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState);
	    }
	    Toast.makeText(getApplicationContext(), "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState, 2000).show();
	    if (developerPayload == null) {
		logProductActivity(itemId, purchaseState.toString());
	    } else {
		logProductActivity(itemId, purchaseState + "\n\t" + developerPayload);
	    }
	    mOwnedItemsCursor.requery();
	    if (itemId.equals(mSku)) {
		switch (purchaseState) {

		case PURCHASED:
		    Toast.makeText(getApplicationContext(), " Already purchased itemId: " + itemId + " " + purchaseState, 2000).show();
		    break;

		default:
		    Toast.makeText(getApplicationContext(), " Item NOT Purchased itemId: " + itemId + " " + purchaseState, 2000).show();
		    break;

		}
	    }
	}

 

And also i am facing one more issue like wheni click on item to purchase , it will says this

"There were problems completing this purchase. Please try again or visit BlackBerry App World Support for more information. (Error ID: 30242) "

 

 

New Contributor
Posts: 6
Registered: ‎09-19-2013
My Device: Playbook
My Carrier: Virgin

Re: Android - Inapp purchase sending request fails.


varunagp1988 wrote:

 

So you mean to say:

 

Instead on this :

 

@Override
public void onStart(Intent intent, int startId) {
    handleCommand(intent);
}

 It should be like this ?

 

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    handleCommand(intent);
    // We want this service to continue running until it is explicitly
    // stopped, so return sticky.
    return START_STICKY;
}

N

Yeah, but you need a null check for the intent argument. There's a bug (well, several) in the original IAB example code from Google. One is that it doesn't handle the service being restarted properly, because it doens't check for null, so it crashes. So add a null check.


varunagp1988 wrote:

 

And also i am facing one more issue like wheni click on item to purchase , it will says this

"There were problems completing this purchase. Please try again or visit BlackBerry App World Support for more information. (Error ID: 30242) "

 

 

No idea. Is it signed properly? you have to be running a draft signed copy of your app that you download thru BB World, not just a debug version installed from eclipse.

 

For restore transactions, look at the Dungeons activity, in particular:

 

/**
* If the database has not been initialized, we send a
* RESTORE_TRANSACTIONS request to Android Market to get the list of purchased items
* for this user. This happens if the application has just been installed
* or the user wiped data. We do not want to do this on every startup, rather, we want to do
* only when the database needs to be initialized.
*/
private void restoreDatabase() {

... Look here...

}

Contributor
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book
My Carrier: Airtel

Re: Android - Inapp purchase sending request fails.

[ Edited ]

ok rockgecko

 

So it should be like this, Please corrext me if i am wrong

 

if (null != intent) {
        handleCommand(intent, startId);
    }

and also we need to add

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
    handleCommand(intent, startId);
    return START_NOT_STICKY;
    }
Contributor
Posts: 42
Registered: ‎11-11-2013
My Device: Black berry Play book
My Carrier: Airtel

Re: Android - Inapp purchase sending request fails.

For all those who are facing issue in solving Android -Runtime for Blackberry version 2 below  are the key points that you need to take care:

 

1) Remove all the signature verification checks in the respective classes.

2) In BillingService class ;

 

Replace onStart with this :

 

@Override
    public void onStart(Intent intent, int startId) {
	if (null != intent) {
	    handleCommand(intent, startId);
	}
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
	handleCommand(intent, startId);
	return START_NOT_STICKY;
    }

 3) Added required permissions in your manifest as suggested by google.

 4) For testing your app, upload the app as draft with SKU and then follow the instructions LIVE TESTING

to test your app.

 

Errors that you might face:

 

1) On click of BUY button nothing happens - cross verify that you have removed signature check everywhere.

2) RESULT_DEVELOPER_ERROR - you cannot test app locally, you have to download your app from Blackberry world in order to test.

 

Many thanks to

 
In helping me to solve the issue, hope it will help some one in future.