Strange behaviour in Android Studio. (p191)


#1

Hi. I’ve been having fun working through the book so far, but have come unstuck at Chapter 10, Page 191.

In the onListItemClick handler, I added the code given in the book to start an instance of CrimeActivity.

It all compiles fine, but when clicking on a list item, I get the dreaded “Unfortunately, CriminalIntent has stopped” message. :cry:

If I comment out the call to startActivity, (or startActivityForResult, which is what I see in the downloadable code archive) then of course the app runs just fine, but obviously no CrimeActivity appears.

I am an Android newbie, so I may be talking rubbish here, but I am just wondering if this might be anything to do with the Android Private Libraries changes relating to ADT version 22? Because I’m using Android Studio (I like it a lot more than Eclipse) I really don’t know if this is the case or not. The fragment-related code from previous chapters is working just fine, but it just doesn’t want to start CrimeActivity from within CrimeListFragment.

Any insight would be appreciated,
Dave


#2

OK - that was embarrassing. I eventually realized what I’d done. When making CrimeListActivity the startup activity for the app, I’d just renamed the existing entry in AndroidManifest.xml. This meant that there was no longer an entry for CrimeActivity in the manifest. Ooops… :laughing:

Dave


#3

Glad to hear you got it fixed up.