[英]Error when switching to another Activity unable to find explicit activity class have you declared this activity in your AndroidManifest
In my project there are two modules of the application.在我的项目中有两个应用程序模块。 When I try to use Intent to go from the Activity of one module to the Activity of another module I get an error that the second Activity is not found in the Manifest.当我尝试使用 Intent 从一个模块的 Activity 转到另一个模块的 Activity 时,我收到一个错误,即在 Manifest 中找不到第二个 Activity。 But this Activity is registered in the Manifest of the second module.但是这个Activity注册在第二个模块的Manifest中。 I have already tried all the answers from similar questions, but the problem remains我已经尝试了类似问题的所有答案,但问题仍然存在
My Intent function:我的意图功能:
public void SendToMetronomeActivity() {
Intent mMetronomeIntent = new Intent();
mMetronomeIntent.setClassName("com.infernal93.metronome.activities", "MainMetronomeActivity");
startActivity(mMetronomeIntent);
}
Manifest of the second module:第二个模块的清单:
<activity android:name="com.infernal93.metronome.activities.MainMetronomeActivity"
android:hardwareAccelerated="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Error:错误:
E/InputEventReceiver: Exception dispatching input event.
E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.infernal93.metronome.activities/MainMetronomeActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1801)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1514)
at android.app.Activity.startActivityForResult(Activity.java:4028)
at androidx.fragment.app.j.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:3989)
at androidx.fragment.app.j.startActivityForResult(FragmentActivity.java:663)
at android.app.Activity.startActivity(Activity.java:4312)
at android.app.Activity.startActivity(Activity.java:4280)
at com.mib.livepartiture.Live.MainActivity.y(MainActivity.java:1356)
New error:新错误:
E/InputEventReceiver: Exception dispatching input event.
E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.infernal93.metronome.activities.MainMetronomeActivity }
declare your activity like this:像这样声明您的活动:
<activity
android:name=".MainMetronomeActivity"
android:label="Preferences" >
<intent-filter>
<action android:name="com.infernal93.metronome.activities.MainMetronomeActivity />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
and use it:并使用它:
Intent i = new Intent("com.infernal93.metronome.activities.MainMetronomeActivity");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.