Recently I wrote a mini game for android2.2. After I put it on google market, I found that some versions of Android 1.5 and Android 1.6 were downloaded. I put it on the simulator and found that none of them can be started. I checked the website for half a day and finally solved the problem. Write down and keep a record.
1. Modify the response method of the BACK key.
Before 2.0, the BACK key responds in onKeyDown.
After 2.0, the BACK key responds in onBackPressed.
To support systems earlier than 2.0, a function is directly added. A better way is to create a common parent class on top of all your own activities. In this case, it will be easier to modify.
Public boolean onKeyDown (int keyCode, KeyEvent event ){
// Back key
If (keyCode = KeyEvent. KEYCODE_BACK ){
OnBackPressed ();
}
Return super. onKeyDown (keyCode, event );
}
Note: Do not add the [@ Override] Comment on the onBackPressed method.
2. Modify the attribute value of filling the parent region in layout.
Before 2.0, It is fill_parent
Fill_parent and match_parent are supported after 2.0
So I renamed all of them [fill_parent].
3. Exception at startup
After the preceding two points are reached, the following exception will still be reported during startup in 1.5.
ERROR/AndroidRuntime (803): Caused by: java. io. FileNotFoundException: res/drawable/title_bar_shadow.9.png
It turns out that you only need to directly create a drawable directory under res and then test the required images. Upgrade title_bar_shadow.9.png.