我是这个世界的新手。当我使用startActivity(intent)时,我遇到了问题。 这是清单:Android中的隐式与显式意图(startActivity(intent)崩溃)
<activity
android:name="com.example.counter.Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.counter.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
这是代码:
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run()
{
try
{
sleep(5000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
finally
{
Intent i=new Intent ("com.example.counter.MainActivity");
startActivity(i);
}
}
};
timer.start();
}
我希望展示飞溅活动5秒钟,然后显示MainActivity。 LogErrors:! https://www.dropbox.com/s/kg7xyp6h4b95itq/Screenshot%202014-02-08%2016.57.36.png 任何解决方案?谢谢
有一个看看不同的[Intent构造函数](http://developer.android.com/reference/android/content/Intent.html#pubctors)。您尝试使用Intent进行启动,该Intent具有不存在的操作并因此出现错误。使用Intent(android.content.Context,java.lang.Class >)而不是 – coderplus