Android Gotchas
Here are some Android development gotchas which I have found
I got this because I overrided onResume but forgot to call super.onResume() DUHH
@Override
protected void onResume() {
super.onResume(); //this was missing
}
Strange exception when starting app.
I added a new activity and found my entire app would not start! And I wasn't even using that app! Things to check
- Be sure that your resource ids are not duplicated. This causes an error when the app starts, even though it might not yet use the resource.
- I have started every resource id with the activity name (e.g. id=myactivity_btnOk)
- Look for other errors in your resource layout files. If you just made a change, back out the change.
Error loading my new activity
- Oops, the activity was not declared in the manifest
- Or oops, it was declared but I did not use the correct namespace
I can't get a non-null location manager
- If you do not have the correct privileges in your manifest, there is no error but no manager comes back.
Some activity launches when I navigate away from a screen.
- Check your event handlers to see if they are causing it. I am trying to deregister event handlers when my activity pauses.
My app raises an exception but I am having trouble seeing why.
- Yuch, I dont love the exception reporting. Try running LOGCAT from ABD. You get much more details.
ABD LOGCAT
LOGCAT is clipping my text.
- Run it from ABD, then the text all wraps
I put data into an intent, but its different when I pull it out!! The reason: makek sure that you know the type of data that you are storing and use the correct get routine to retrieve it. In my case, I was storing a long but using getIntExtra instead of getLongExtra. Duh.
Intent data = new Intent();
data.putExtra("NumberOfCats", numberOfCats);
//
//
int numStored = data.getIntExtra("NumberOfCats"); //gets wrong value because numberOfCats is a long and not an int!
I made a custom list adapter with EditText and such but now it doesn't select or scroll.
Yuch, I am going to blog on this. If the view inside the list can accept clicks/touches, then it screws up the OnItemSelected listener. So you are better off to use things likeTextViews. But I got this to work - see upcoming blog entry.
No comments:
Post a Comment