/ *这是我的启动器活动,基本上是一个启动画面,等待5秒但是intent.pls有一些问题帮助 * /
package com.hfad.practice;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class Starting extends AppCompatActivity {
public void start()
{
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_starting);
Thread timer=new Thread()
{
public void run()
{
try
{
sleep(5000);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
finally
{
Intent intent=new Intent(this,MainActivity.class); /*
here it is showing an error thats mentioned in the title*/
startActivity(intent);
}
}
};
timer.start();
}
}
答案 0 :(得分:3)
更改
Intent intent=new Intent(this,MainActivity.class);
带
Intent intent=new Intent(Starting.this,MainActivity.class);
在您的情况下this
引用Thread
子类,而Intent
的第一个参数是Context
对象