Reputation: 1363
I have a simple program for splash screen. In which I have created a class that impements Runnable
and overrides run()
method.
class mysplash implements Runnable {
@Override
public void run() {
try {
Intent i = new Intent(getApplicationContext(), MainActivity.class);
startActivity(i);
finish();
} catch (InterruptedException e) {
System.out.println("exception");
}
}
}
If I write following code , Eclipse shows an error:
Remove catch clause
I have a prior experience in Java and AFAIK we should write the content of run() method in try - catch block to avoid interruptedexception
for thread.
I am a newbie in Android. Can anyone explain why exception handling is required for run()
method in Java but not in Android?
Upvotes: 1
Views: 1025
Reputation: 3907
Its because InterruptedException
will never be thrown from your try code block.
Upvotes: 3