My project is coming along nicely. I learned the hard way that the Android emulator is quite different than an actual device so when I got my phone back running my project on it pointed out a number of issues that I hadn’t thought of because they weren’t exposed with the emulator.
Here are some issues I tackled with recently:
- If you have multiple <intent-filter sections in yourAndroidManifest.xml defining:
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
then each of those sections will create icons for your application with no other identification saying which is which.. Can be a bit confusing on which icon to press to run what main mechanism
- If you are launching an custom intent/activity from preferences DO NOT specify data= in your preferences.xml unless you are set to handle it, otherwise you will get a “cannot find activity” exception. This took me several hours to discover, a lot of head scratching and swearing because I got lazy and never deleted the data= part that I copied from Google’s example code.
- The bundle as the argument to onCreate() for your activity is actually very useful and tied to onSaveInstanceState(), this I supposed is common sense but no example I read actually showed them being used together so some digging exposed to me how to use it, very handy.
- PreferenceManager.getDefaultSharedPreferences() is super easy to use, beats property file loading/saving which I use at work a lot.
- My app is targeting Android 2.1 so I couldn’t use Camera.getNumberOfCameras(). I was using Camera.open() to find out if the device has a camera but not calling Camera.release() which caused some really strange exceptions later on in my code
- this information on screens proved very important to several UI problems I was having (multi-touch), should be fundamental reading for anyone learning Android programming.