I have this Exception
while running my application which cause to stop the app.
the exception is: ThreadGroup.uncaughtException(Thread, Throwable) line:689
I clear the question, I have 2 activities, as follows:
1) HomeActivity: which contains a button "Open Emsakkeya" which open the second activity
2) EmsakeyyaActivity: in this Activity
I set and display some data...
when I debug the application it crashes when I call the second activity in the button keyListener
public class HomeActivity extends ActionBarActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
setTitle("Home Screen");
Button emsakeyya_btn=(Button) findViewById(R.id.emsakeyya_btn);
emsakeyya_btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(HomeActivity.this, EmsakeyyaActivity.class);
startActivity(i);
}
});
}
the second Activity
public class EmsakeyyaActivity extends ActionBarActivity {
EmsakeyyaActivity()
{
fajrTime = new Time();
shuroqTime = new Time();
duhrTime = new Time();
asrTime = new Time();
maghrebTime = new Time();
eshaaTime = new Time();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emsakeyya);
String zoneName = "zoneName";
AllPraysTime(fajrTime,shuroqTime,duhrTime,asrTime,maghrebTime,eshaaTime);
currentPrayTime = (TextView) findViewById(R.id.currentSalah_lbl2);
nextPrayTime = (TextView) findViewById(R.id.nxtSalah_lbl2);
fajrPrayTime = (TextView) findViewById(R.id.fajrPrayTime_lbl2);
shuroqPrayTime = (TextView) findViewById(R.id.shuroqPrayTime_lbl2);
duhrPrayTime = (TextView) findViewById(R.id.duhrPrayTime_lbl2);
asrPrayTime = (TextView) findViewById(R.id.asrPrayTime_lbl2);
maghrebPrayTime = (TextView) findViewById(R.id.maghrebPrayTime_lbl2);
eshaaPrayTime = (TextView) findViewById(R.id.eshaaPrayTime_lbl2);
SetPraysTime();
}
any idea about this exception?! and what should i do
Make the constructor for EmsakeyyaActivity public, as shown below:
Also, as a general rule, it is better to initialize your activity in the onCreate() method and not use constructors.