Reputation: 2241
I currently have a simple app in the market, now I tried installing it on an Android 4.0 device. But it fails after my Splashscreen closes. I send a rapport and got this as feedback:
Crash
java.lang.UnsupportedOperationException
Thread.stop()
and
java.lang.UnsupportedOperationException
at java.lang.Thread.stop(Thread.java:1076)
at java.lang.Thread.stop(Thread.java:1063)
at com.lars.PSVWebView.SplashScreen$1.run(SplashScreen.java:35)
this is the code, since last edit:
package com.lars.DrinkRecOrder;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
Intent intent = new Intent();
intent.setClass(SplashScreen.this, DrinkRecOrderActivity.class);
}{
/* start the activity */
startActivity(new Intent("com.lars.DrinkRecorder.splashscreen.DrinkRecorderActivity"));
}
}, 500);
}
}
So this is my new code... no errors, but doesn't work either, my app crashes at startup. By the way... same splashscreen code, different app
Upvotes: 1
Views: 1457
Reputation: 2241
This was the answer!
package com.lars.DrinkRecOrder;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
/* start the activity */
startActivity(new Intent("com.lars.DrinkRecOrder.splashscreen.DrinkRecOrderActivity"));
}
}, 5000);
}
}
Upvotes: 0
Reputation: 11211
You can use this method:
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
Intent intent = new Intent();
intent.setClass(SplashScreen.this, NextActivity.class);
}
/* start the activity */
startActivity(intent);
}
}, SPLASH_SCREEN_TIME_IN_MILLISECONDS);
I think it's far better and elegant than Thread.sleep()
Upvotes: 2
Reputation: 8176
Read the documentation on Thread.stop()
.
This method is deprecated. because stopping a thread in this manner is unsafe and can leave your application and the VM in an unpredictable state.
Throws
UnsupportedOperationException
.
Upvotes: 1