I want to test out crash report using acra but the first step is I need to simulate a fatal crash in Android using code.
Any idea?
A very simple approach... and is very important to understand that why it happened.
Try initiating a variable in onCreate()
before the setContentView()
method, then use it to call a method or variable or try registering it to some listener..
Eg:
Button b;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
b = (Button)findViewById(R.id.butt);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
}
});
setContentView(R.layout.main);
}
This crashed, because before setContentView()
none of the components/view in the main.xml layout got their ids.