好了第二页,所以我使用本教程创建了一个非常简单的启动画面:安卓:初始屏幕重新打开应用程序,即使闪屏时,应用程序是退出
http://p-xr.com/android-tutorial-how-to-make-a-basic-splash-screen/
的问题是,如果用户点击主页按钮或后退按钮以在启动屏幕持续时间期间退出应用程序,然后如果用户没有退出,则启动屏幕完成后应用程序将重新打开到第二屏幕。
我的代码几乎是教程。任何帮助?
感谢
好了第二页,所以我使用本教程创建了一个非常简单的启动画面:安卓:初始屏幕重新打开应用程序,即使闪屏时,应用程序是退出
http://p-xr.com/android-tutorial-how-to-make-a-basic-splash-screen/
的问题是,如果用户点击主页按钮或后退按钮以在启动屏幕持续时间期间退出应用程序,然后如果用户没有退出,则启动屏幕完成后应用程序将重新打开到第二屏幕。
我的代码几乎是教程。任何帮助?
感谢
我已经修改了代码,使用的生命周期方法更好。喜欢改变它。 :)
public class SplashScreen extends Activity {
protected int _splashTime = 5000;
private Thread splashTread;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
final SplashScreen sPlashScreen = this;
// thread for displaying the SplashScreen
splashTread = new Thread() {
@Override
public void run() {
try {
synchronized(this){
wait(_splashTime);
}
} catch(InterruptedException e) {}
finally {
if(!isFinishing()) // This pretty useful boolean val tells if
//user has pressed the back button. very useful.
{Intent i = new Intent(SplashScreen.this, Main.class);
startActivity(i);
finish();
}
stop();
}
}
};
splashTread.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Toast.makeText(this,"exec---",Toast.LENGTH_LONG).show();
synchronized(splashTread){
splashTread.notifyAll();
}
}
return true;
}
@Override
protected void onPause() {
super.onPause();
if(splashTread.getState()==Thread.State.TIMED_WAITING){
//Thread is still waiting and Activity is paused. Means user has pressed Home. Bail out
finish();
}
}
}
我的观点是,使用闪屏并不频繁,但也许需要。如果你在屏幕后面进行繁重的工作(比如游戏)。
非常感谢。截至目前为止的初始屏幕是无用的(我明白为什么人们不喜欢它们),但我的推理是这样的:1.我正在合作的人想要它2.我可能需要那段时间来从服务器(很多图像,因此可能需要一些时间)。另外,我是新的应用开发,并认为这将是有趣的实施一个,并知道如何 – LiverpoolFTW 2012-03-20 17:54:02
欢迎。如果数据巨大,可能需要这样做。虽然在加载图片的情况下,请选择“延迟加载图片”(Romain Guy,Android Shelves或其他),以便用户在加载图片时可以继续使用您的应用。 – Akhil 2012-03-20 18:02:56
感谢您的建议,生病了看。 – LiverpoolFTW 2012-03-20 18:08:16
“错”?以什么方式? – LiverpoolFTW 2012-03-20 17:35:22
在他们获得无缝用户体验的方式中出现错误,通常在功能上毫无意义,大部分时间只是一个计时器等待(并让用户等待) – njzk2 2012-03-20 17:39:44