gpt4 book ai didi

android - 我尝试在Android Studio上模拟项目时出错

转载 作者:行者123 更新时间:2023-12-02 11:09:15 25 4
gpt4 key购买 nike

当我尝试在模拟器上运行时出现此错误:

03-24 11:42:49.843 1120-1120/com.mindrain.touchbreak E/AndroidRuntime﹕ FATAL EXCEPTION: main android.content.ActivityNotFoundException: Unable to find explicit activity class {com.mindrain.touchbreak/android.view.Menu}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417) at android.app.Activity.startActivityForResult(Activity.java:3370) at android.app.Activity.startActivityForResult(Activity.java:3331) at android.app.Activity.startActivity(Activity.java:3566) at android.app.Activity.startActivity(Activity.java:3534) at com.mindrain.touchbreak.Splash$1.run(Splash.java:26) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method)



在 list 中,我有这个:
    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mindrain.touchbreak"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.write_external_storage"/>
<uses-permission android:name="android.permission.read_external_storage"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.set_orientation"/>

<uses-sdk android:minSdkVersion="3"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainMenu"
android:label="@string/app_name" >
</activity>

<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=".Splash2"
android:label="@string/app_name">
</activity>

</application>

</manifest>

在我的启动 Activity 中,我有以下内容:
package com.mindrain.touchbreak;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;


public class Splash extends Activity {


private final int SPLASH_DISPLAY_LENGTH = 1000;


@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splash_screen);

new Handler().postDelayed(new Runnable(){
@Override
public void run() {

Intent mainIntent = new Intent(Splash.this,Menu.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
private void openApp(){
startActivity(new Intent(this,Splash2.class));
finish();

}
}

在我的Splash2 Activity 中,这是:
package com.mindrain.touchbreak;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaActionSound;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;


public class Splash2 extends Activity {


private final int SPLASH_DISPLAY_LENGTH = 1000;


@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splash_screen_2);

new Handler().postDelayed(new Runnable(){
@Override
public void run() {

Intent mainIntent = new Intent(Splash2.this,MainMenu.class);
Splash2.this.startActivity(mainIntent);
Splash2.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
private void openApp(){
finish();
startActivity(new Intent(this,MainMenu.class));
}
}

在我的MainMenu Activity 中:
package com.mindrain.touchbreak;

import android.app.Activity;
import android.media.MediaPlayer;
import android.view.View;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class MainMenu extends Activity implements View.OnClickListener {

public MediaPlayer mp = null;

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.start:
//startActivity(Game);
break;
case R.id.options:
//startActivity();
break;
}

}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_menu);

Button b = (Button) findViewById(R.id.sound);
b.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if (mp == null) {
//mp = MediaPlayer.create(MainMenu.this, R.raw.menu);
mp.start();
} else {
mp.stop();
mp = null;
}
}

});
}
}

错误在哪里?

谢谢

最佳答案

我认为你应该改变

Intent mainIntent = new Intent(Splash.this,Menu.class);


Intent mainIntent = new Intent(Splash.this,MainMenu.class);

在启动 Activity 中。

关于android - 我尝试在Android Studio上模拟项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29231988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com