1

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

HendraWD
  • 2,984
  • 2
  • 31
  • 45
BDeveloper
  • 1,175
  • 6
  • 24
  • 44
  • Are there any other error messages in your error log? – summea Jun 22 '15 at 16:48
  • 1
    There´s a message into your LogCat indicated as "Caused by..." ? – Jorgesys Jun 22 '15 at 16:50
  • Please add your LogCat to the post, but don`t forget to declare your Activity in your manifest. I always forget it :) – narancs Jun 22 '15 at 16:52
  • thanks all, but where i can find this LogCat? – BDeveloper Jun 22 '15 at 16:55
  • i've declared all my activities in the manifest – BDeveloper Jun 22 '15 at 16:56
  • For the LogCat question: are you using Android Studio or Eclipse (or something else) for your IDE? – summea Jun 22 '15 at 16:59
  • Eclipse :) ... could the view cause this type of exception.. i mean the layout.. – BDeveloper Jun 22 '15 at 17:01
  • http://stackoverflow.com/questions/2364811/how-do-i-write-outputs-to-the-log-in-android – Jorgesys Jun 22 '15 at 17:02
  • For Eclipse, you should be able to enable the LogCat view by following [these instructions](http://stackoverflow.com/a/3280126/1167750). The LogCat window should then [appear like in this screenshot](http://i.stack.imgur.com/fINQT.gif). In LogCat, you can see a longer list of errors... if you could copy/paste the longer list of errors in your question, that might help! – summea Jun 22 '15 at 17:09
  • i caught the exception, thank you all for your answers and support :) – BDeveloper Jun 22 '15 at 21:25

1 Answers1

1

Make the constructor for EmsakeyyaActivity public, as shown below:

public EmsakeyyaActivity()
{
    fajrTime = new Time();
    shuroqTime = new Time();
    duhrTime = new Time();
    asrTime = new Time();
    maghrebTime = new Time();
    eshaaTime = new Time();
}

Also, as a general rule, it is better to initialize your activity in the onCreate() method and not use constructors.

Bob Snyder
  • 37,759
  • 6
  • 111
  • 158