我在开始活动时遇到错误,到目前为止我一直无法找到解决方案,是否有任何人可以帮助我排查代码?
飞溅:
package inno.games;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity{
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle Jonas) {
// TODO Auto-generated method stub
super.onCreate(Jonas);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
ourSong.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent introscreenactivity = new Intent("Inno.Games.INTROSCREEN");
startActivity(introscreenactivity);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}
初始化下一个活动时会出现错误。
下一次活动的代码 (我想在buttonclick上开始新的活动)
package inno.games;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
public class Introscreen extends Activity {
Button proceed;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.intro);
proceed = (Button) findViewById(R.id.bProceed);
proceed.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Introscreen.this, BillardScoreboardActivity.class);
Introscreen.this.startActivity(myIntent);
}
});
}
这是我的表现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="inno.games"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".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=".Intro"
android:label="@string/app_name" >
<intent-filter>
<action android:name="Inno.Games.INTROSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".BillardScoreboardActivity"
android:label="@string/app_name" >
</activity>
</application>
SPLASH是obv启动画面 IINTROSCREEN是关注启动后的活动 BILLARDSCOREBOARDACTIVITY是我想在introscreen GUI上启动按钮的活动。
答案 0 :(得分:1)
您需要更正此部分:
<activity
android:name=".Intro"
android:label="@string/app_name" >
<intent-filter>
<action android:name="Inno.Games.INTROSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
用这个:
<activity
android:name=".Introscreen"
android:label="@string/app_name" >
</activity>
实际上有什么问题? 您尚未使用您创建的确切名称声明活动。你只给了.Intro而不是.Introscreen
答案 1 :(得分:1)
更改您的清单文件中的活动名称
android:name=".Intro"
到
android:name=".Introscreen "