gpt4 book ai didi

java - android.content.ActivityNotFoundException : Unable to find explicit activity class in Android

转载 作者:行者123 更新时间:2023-11-30 01:45:52 26 4
gpt4 key购买 nike

在 MainActivity 类中,我有以下代码转到 settings.class。

Intent intent1 = new Intent(MainActivity.this,Settings.class);
startActivity(intent1);

但是我遇到了异常。 logcat 显示以下错误。

11-17 12:31:50.245: E/AndroidRuntime(11166): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.commlink.messaging/com.commlink.messaging.Settings}; have you declared this activity in your AndroidManifest.xml?
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1634)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1430)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.Activity.startActivityForResult(Activity.java:3507)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.Activity.startActivityForResult(Activity.java:3459)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.Activity.startActivity(Activity.java:3710)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.Activity.startActivity(Activity.java:3678)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.commlink.messaging.MainActivity.onOptionsItemSelected(MainActivity.java:105)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.Activity.onMenuItemSelected(Activity.java:2674)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1074)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:206)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.widget.AdapterView.performItemClick(AdapterView.java:299)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.widget.AbsListView.performItemClick(AbsListView.java:1152)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3014)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.widget.AbsListView$3.run(AbsListView.java:3865)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.os.Handler.handleCallback(Handler.java:808)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.os.Handler.dispatchMessage(Handler.java:103)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.os.Looper.loop(Looper.java:193)
11-17 12:31:50.245: E/AndroidRuntime(11166): at android.app.ActivityThread.main(ActivityThread.java:5330)
11-17 12:31:50.245: E/AndroidRuntime(11166): at java.lang.reflect.Method.invokeNative(Native Method)
11-17 12:31:50.245: E/AndroidRuntime(11166): at java.lang.reflect.Method.invoke(Method.java:515)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
11-17 12:31:50.245: E/AndroidRuntime(11166): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
11-17 12:31:50.245: E/AndroidRuntime(11166): at dalvik.system.NativeStart.main(Native Method)

我在 menifest.xml 中贴标了 Settings.class 。我的 menifest.xml 文件如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.commlink.messaging"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyAppTheme" >
<activity
android:name="com.commlink.messaging.MainActivity"
android:label="@string/app_name"
android:uiOptions="splitActionBarWhenNarrow" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>

<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>

<activity
android:name="com.commlink.messaging.New_Message"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name="com.commlink.messaging.Settings"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>


<receiver android:name=".SmsBroadcastReceiver"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
</intent-filter>
</receiver>

<!-- BroadcastReceiver that listens for incoming MMS messages -->
<receiver android:name=".MmsReceiver"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>

<!-- Activity that allows the user to send new SMS/MMS messages -->
<activity android:name=".ComposeSmsActivity"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>

<!-- Service that delivers messages from the phone "quick response" -->
<service android:name=".HeadlessSmsSendService"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
</application>
</manifest>

我该怎么做才能解决这个异常?

最佳答案

像这样更改您的 AndroidManifest.xml。像这样更改您的 android:name 。因为您的包名称已经在 AndroidManifest.xml 之上构建。

   <activity
android:name=".Settings"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

关于java - android.content.ActivityNotFoundException : Unable to find explicit activity class in Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33750961/

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