故障排除 - 活动启动
我在开始活动时遇到错误,到目前为止我一直无法找到解决方案,是否有人可以帮助我对代码进行故障排除?
SPLASH:
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();
}
}
初始化下一个活动时出现错误。
下一个活动的代码 (我想在单击按钮时启动一个新活动)
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 是我想在屏幕 GUI 上单击按钮时启动的活动。
I'm getting errors upon start of my activities, and i've been unable to find the solution so far, is there by any chance anyone who could help me troubleshooting my code?
SPLASH:
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();
}
}
An error appears upon initialization of the next activity.
CODE FOR NEXT ACTIVITY
(which i want to start a new activity on 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);
}
});
}
THIS IS MY MANIFEST:
<?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 is obv splash screen
IINTROSCREEN is the activity following splash
And BILLARDSCOREBOARDACTIVITY is the activity i want to start uppon buttonclick on introscreen GUI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将清单文件中的活动名称更改
为
change your activity name in your Manifest file
into
您需要更正这部分:
使用以下内容:
实际上有什么问题?
您尚未使用您创建的活动的确切名称来声明活动。您只给出了 .Intro 而不是 .Introscreen
You need to correct this part:
with this:
What is wrong actually?
You haven't declared activity with its exact name that you have created. You have given only .Intro instead of .Introscreen