Runnable用于添加程序启动页
public class Loading extends Activity implements Runnable{
public final int KEEP_TIME = 3000;
private final int REQUEST_SYSTEMSET = 1;
private final int REQUEST_MAINVIEW = 2;
private int loginFlag;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.loading);
CaeHelper.startCAE(this);
loginFlag = UHomeUtil.loadLoginFlag(this);
new Thread(this).start();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode != RESULT_CANCELED){
switch (requestCode) {
case REQUEST_SYSTEMSET:
Intent intent = new Intent(this,UHomeMain.class);
startActivity(intent);
finish();
break;
default:
break;
}
}
}
@Override
public void run() {
try {
Thread.sleep(KEEP_TIME);
} catch (InterruptedException e) {
e.printStackTrace();
}
Intent intent = new Intent();
if(loginFlag == 0){
intent.setClass(this, SystemSet.class);
startActivityForResult(intent, REQUEST_SYSTEMSET);
} else {
intent.setClass(this, UHomeMain.class);
startActivityForResult(intent, REQUEST_MAINVIEW);
finish();
}
}
}