知道主要逻辑是设置主线程睡两秒钟,可是代码老是有问题,大神们帮我看下代码吧,或者给我一段正确的代码,我自己研究下,谢谢啦
下面是代码
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
//setContentView(R.layout.activity_main);
requestWindowFeature(Window.FEATURE_NO_TITLE);
//设置全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
MyTimer timer=new MyTimer();
timer.start();
}
private static final int Goto=0;
Handler handler=new Handler(){
public void handleMessage(Message mes){
switch (mes.what) {
case Goto:
Intent intent=new Intent();
intent.setClass(MainActivity.this,Welcome.class);
startActivity(intent);
finish();
break;
default:
break;
}
}
};
public class MyTimer extends Thread{
public MyTimer(){
}
public void run(){
try {
sleep(1000);
handler.sendEmptyMessage(Goto);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
安卓编程?安卓开发
------解决方案--------------------
前面一个是当前Activity,后面一个是目标Activity.........
------解决方案--------------------
startActivity(new Intent(Activity_Main.this,Activity_NewPage.class));
我想问下这行代码的(Activity_Main.this,Activity_NewPage.class)这两个参数应该怎么填,是什么意思哦,求大神详解
前面一个是当前Activity,后面一个是目标Activity.........
为什么我设置的每次都是过两秒就强制终止了、、
Activity_NewPage没在Manifest里声明吧?