Come intercettare le eccezioni causate da un file di layout-xml malformato?
-
26-09-2019 - |
Domanda
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 exception is thrown at this line.
setContentView(R.layout.main);
} //Exception will be thrown after this line. Where to catch it?
}
Soluzione
Sei serio? Quel genere di cose non può essere solo " Catched " ... Devono essere fissati. Basta correggere il file XML e il gioco è fatto ... non ha senso per la cattura, come eccezione; cosa vorresti fare dopo la cattura?
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow