我有两个初始屏幕,首先是静态的,然后在他启动第二个初始屏幕后随机切换不同的初始屏幕。我的问题是当开始第二个活动时,直到活动工作旋转手机第二个活动重新开始旧的活动。我担心什么时候飞溅屏幕结束,我的应用程序启动我有两个工作应用程序。
这是我的第一个静态闪屏。
package com.readytechgo;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import android.os.Bundle;
import android.widget.ImageView;
import android.app.Activity;
import android.content.Intent;
public class FirstSplashScreen extends DefaultActivity {
int timeout = 2000; // Choose the delay (1000 = 1 second)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
setFonts();
// Randomise a background
int[] yourListOfImages= {R.drawable.intro};
Random random = new Random(System.currentTimeMillis());
int posOfImage = random.nextInt(yourListOfImages.length);
ImageView imageView= (ImageView) findViewById(R.id.imageView1);
imageView.setBackgroundResource(yourListOfImages[posOfImage]);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
//Redirecting to the home page
Intent redirect = new Intent(getApplicationContext(), SplashScreen.class);
startActivity(redirect);
finish();
}
}, timeout);
}
}
这是我的第二个闪屏……和他在一起我有问题……
package com.readytechgo;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import android.os.Bundle;
import android.widget.ImageView;
import android.app.Activity;
import android.content.Intent;
public class SplashScreen extends DefaultActivity {
int timeout = 2000; // Choose the delay (1000 = 1 second)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.random_splash);
setFonts();
// Randomise a background
int[] yourListOfImages= {R.drawable.home_image1_portrait,R.drawable.home_image2_portrait,R.drawable.home_image3_portrait,R.drawable.home_image4_portrait};
Random random = new Random(System.currentTimeMillis());
int posOfImage = random.nextInt(yourListOfImages.length);
ImageView imageView= (ImageView) findViewById(R.id.randomImageView);
imageView.setBackgroundResource(yourListOfImages[posOfImage]);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
//Redirecting to the home page
Intent redirect = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(redirect);
finish();
}
}, timeout);
}
}