General
A small bug in the Android In-App Billing demo app causes “Item Not Found”
Important: This is not a bug in the API! It is only a bug in the demo Dungeons application that Google provides.
Several months ago (May, 2012) Google released the new version (v2) of the Android In-App Billing API that supports auto-renewing subscriptions. That was a huge step forward! Thank you Google!
I started implementing this in my apps soon after but then discovered one small annoying bug in their demo application (Dungeons). It causes the the incorrect response of “item not found”.
I published the solution a couple of months ago to stackoverflow and the official android developers forum.
The bug is in the onClick for the Purchase button in the Dungeons class of the sample application.
The supplied method has a bug in the if {} else if {} statement where it causes the mBillingService.requestPurchase to be called twice, when the selected item is not a subscription item (mManagedType != Managed.SUBSCRIPTION). So the same item will be requested twice, once with an item type of “inapp” (which is the valid request) and immediately after that with an item type of “subs” (which is incorrect and it shows “item not found”).
Here is the buggy code:
if (mManagedType != Managed.SUBSCRIPTION &&
!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
} else if (!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_SUBSCRIPTION, mPayloadContents)) {
// Note: mManagedType == Managed.SUBSCRIPTION
showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
}
To fix this, add mManagedType == Managed.SUBSCRIPTION to the else if above.
Here is how the function should look:
public void onClick(View v) {
if (v == mBuyButton) {
if (Consts.DEBUG) {
Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
}
if (mManagedType != Managed.SUBSCRIPTION &&
!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
} else if (mManagedType == Managed.SUBSCRIPTION && !mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_SUBSCRIPTION, mPayloadContents)) {
// Note: mManagedType == Managed.SUBSCRIPTION
showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
}
} else if (v == mEditPayloadButton) {
showPayloadEditDialog();
} else if (v == mEditSubscriptionsButton) {
editSubscriptions();
}
}
Depeche Mode Live in Tampa
I finally materialized a teenage dream and went to see Depeche Mode live last Friday. It was everything I expected even more. They sounded incredible and Dave Gahan’s voice was as good as ever. It could have been the acoustics at the amphitheater but the live performance of the songs was better than the studio versions. Martin Gore also sang 2-3 of his songs and did a great job of it.
At the concert I felt like I had to go see them again the next day in Fort Lauderdale. May be I should have…
I took a few videos. The quality is not that bad considering I took them with my iPhone.
Their “Tour of the Universe” continues to Mexico and then back in Europe. This could be the last chance to go see them live.
10 Youtube URL Tricks You Should Know About
I recently stumbled upon this while watching the diggnation podcast (episode 201). Check it out:
Has Apple become like Mirosoft? Or may be even worse?
I love Apple!
I cannot live without my iPod, much less without my iPhone! The “I am a Mac, I am a PC” commercials on TV are so adorable… Sometimes I rewind my DVR just to see one of those commercials again. In these moments I tell myself “Show that evil empire Microsoft how things are done!”.
But then… I must have been brain dead for a while! You see, what got me is that I have always been for a free market and fair competition. And what Microsoft was doing was not right. No two ways about it. Apple was the company that materialized those feelings and stood up to Microsoft. Naturally, I (like many others) fell for it and blindly screamed “Go Apple!”.
It turns out that I have supported a company that became worse than the one it had set out to defy.
Apple said that if you want to have an iPod, you can only use it with iTunes and if you want to buy music for it… guess what?… you need iTunes for that as well. Same applies to the iPhone with the only difference that you have to be an AT&T customer. Oh yeah… and all these songs you might have bought from Apple, you can’t put on any other mp3 player but on an iPod, unless you remove the DRM protection.
On the computer front things do not look much more different. Mac OS X can legally run only on officially approved Apple hardware and vise versa. If you like the OS, well your only chance is to drop some major cash for the hardware as well. This goes over and beyond what Microsoft has ever attempted to do. After all you can run Windows on anything you feel like.
I am a huge believer in FOSS and Apple has shaped to be the absolute opposite of this philosophy. Even though their OS is built on top of FreeBSD and NetBSD, and they have ported a number of Linux applications to Mac OS X, they have not contrubuted back to the community at all. They even officially announced that iTunes will not be released for Linux. I would like to think that the only reason for this is because they know that Linux users are not going to tollerate DRM content anyway.
There is no silver bullet
So… I moved to the dark side.
I have always developed web applications mostly from scratch- I create the databases, write the code and make the design. But today, as you can see, I started a personal blog. And rather than making the site from scratch I resorted to using a popular blog/cms solution.
I should have known what to expect. After all I used to do web development on a MS CMS 2001 platform at some point in my life, but it still caught me be surprise. I had forgotten how clumsy things can be. On the one hand you still have to program any customizations you have in ASP, PHP, Java or whatever the case might be, and on the other you have to get familiarized with the API of the new CMS solution to accomplish even the simplest tasks.
I guess there is no silver bullet… I gained some by not having to do the simple things myself- the design, the programming of the standard features that I would need for a blogging site but I also lost some, by having now to get used to this new environment that feels like a suffocating wrap around me.
There is always some learning curve… even for the smallest things.
Search
Archive
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Apr | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
Recent Comments
- Olivier on Dynamic Port Forwarding with SOCKS over SSH
- Ld7 on How to connect your Android phone to Ubuntu to do development, testing, installations or tethering
- get more Info on How to get Picasa images using the Image Picker on Android devices running any OS version
- Casper on How to detect a user pan/touch/drag on Android Map v2
- Install SSH as socks proxy for dynamic port forwarding | Steve Constine on Dynamic Port Forwarding with SOCKS over SSH
Categories
Blogroll
Online Tools
Other
BLOG ARCHIVE
- April 2013 (1)
- November 2012 (2)
- August 2012 (1)
- May 2012 (1)
- March 2012 (1)
- November 2011 (1)
- August 2011 (1)
- April 2011 (1)
- January 2011 (2)
- September 2010 (1)
- August 2010 (2)
- July 2010 (2)
- June 2010 (2)
- May 2010 (1)
- January 2010 (2)
- December 2009 (2)
- November 2009 (3)
- October 2009 (1)
- September 2009 (3)
- July 2009 (1)
- May 2009 (1)
- March 2009 (1)
- February 2009 (2)
- January 2009 (2)
- December 2008 (1)
- November 2008 (4)
- October 2008 (5)
