public class MyActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//R.layout.main has an illegal element (e.g. no layout_height attribute)
//But no ecxeption is thrown at this line.
setContentView(R.layout.main);
} //Exception will be thrown after this line. Where to catch it?
}
views:
18answers:
1
+3
A:
Are you serious? That kind of things cannot be just "catched"... they have to be fixed. Just fix your XML file and that's it... it does not make sense to catch such as Exception; what would you do after catching it?
Cristian
2010-09-29 13:48:01
+1 to Cristian. @OneWorld: If your Layout XML is malformed then your application is broken.
Octavian Damiean
2010-09-29 13:50:53
@Christian: Of course this things must be fixed. However, it also must be possible to catch those things. @Octavian: If the XML of an activity is malformed then this Activity is broken, not the application. So, I can finish it, show appropriate Toasts and Log the error.
OneWorld
2010-09-29 14:18:11
@OneWorld: Why should the layout of an activity you built be malformed? This makes no sense. Why would you publish an application with a broken activity?
Flo
2010-09-29 14:39:31
@OneWorld trust me, while developing with Android you will find that not all Exceptions can be caught. Just fix your layout, case closed.
Cristian
2010-09-29 14:53:15