简体   繁体   English

ActivityNotFoundException:无法找到显式活动类?

[英]ActivityNotFoundException: Unable to find explicit activity class?


Yes, I know that this question has been asked so many times, but none of the answers actually work for me? 是的,我知道这个问题被问过很多次了,但是没有一个答案对我有用吗? I think maybe someone just needs to interpret my code. 我认为也许有人只需要解释我的代码即可。

My application launches on a SplashScreen.java for 10 seconds, and then should load MainActivity.java . 我的应用程序在SplashScreen.java上启动10秒钟,然后应加载MainActivity.java。 However, when I run my application, it launches the SplashScreen but then after 10 seconds, MainActivity does not load and the app say's it has stopped. 但是,当我运行我的应用程序时,它将启动SplashScreen,但是10秒钟后,MainActivity无法加载,并且该应用程序说它已经停止。

I checked the run log, and it say's "android.content.ActivityNotFoundException: Unable to find explicit activity class {com.msp.supercarsounds/com.msp.supercarsounds.MainActivity}; have you declared this activity in your AndroidManifest.xml?" 我检查了运行日志,并说“ android.content.ActivityNotFoundException:无法找到显式的活动类{com.msp.supercarsounds / com.msp.supercarsounds.MainActivity};您是否已在AndroidManifest.xml中声明了此活动?”

AndroidManifest.xml: AndroidManifest.xml中:

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.msp.supercarsounds"> <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="22"/> <uses-permission android:name="android.permission.INTERNET"/> <application android:largeHeap="true" android:allowBackup="true" android:icon="@mipmap/carsounds_logo" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name="com.msp.supercarsounds.SplashScreen" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <activity android:name="com.msp.supercarsounds.MainActivity" /> <activity android:name=".AudiPrimary" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.RegisterApplication" android:label="Register Appliction" android:theme="@style/AppTheme" /> <activity android:name="com.msp.supercarsounds.Porsche" android:label="Porsche" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.MercedesBenz" android:label="Mercedes-Benz" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.Lamborghini" android:label="Lamborghini" android:theme="@style/AppTheme" /> <activity android:name="com.msp.supercarsounds.Ferrari" android:label="Ferrari" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.BMW" android:label="BMW" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.Jaguar" android:label="Jaguar" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.AstonMartin" android:label="Aston Martin" android:theme="@style/AppTheme" /> <activity android:name="com.msp.supercarsounds.ChooseManufacturer" android:label="Choose Manufacturer" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.Audi" android:label="Audi" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> <activity android:name="com.msp.supercarsounds.About" android:label="About" android:theme="@style/AppTheme" /> <activity android:name="com.msp.supercarsounds.Contact" android:label="Contact" android:theme="@style/AppTheme" /> <service android:name=".MyFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING.EVENT"/> </intent-filter> </service> <service android:name=".MyFirebaseInstanceIDService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE.ID.EVENT"/> </intent-filter> </service> </manifest> 


SplashScreen.java: SplashScreen.java:

 package com.msp.supercarsounds; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class SplashScreen extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash_screen_layout); Thread myThread = new Thread() { @Override public void run() { try { sleep(10000); Intent startMainActivity = new Intent(getApplicationContext(), MainActivity.class); startActivity(startMainActivity); finish(); } catch (InterruptedException e) { e.printStackTrace(); } } }; myThread.start(); } } 

MainActivity.java: MainActivity.java:

 package com.msp.supercarsounds; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Html; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.widget.CheckBox; public class MainActivity extends AppCompatActivity { public static final String PREFS_NAME = "MyPrefsFile1"; public CheckBox dontShowAgain; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void clickedAbout(View view) { final int result = 1; Intent AboutButtonClicked = new Intent (this, About.class); AboutButtonClicked.putExtra("About", "MainActivity"); startActivityForResult(AboutButtonClicked, result); } public void clickedContact(View view) { final int result = 1; Intent ContactButtonClicked = new Intent (this, Contact.class); ContactButtonClicked.putExtra("Contact", "MainActivity"); startActivityForResult(ContactButtonClicked, result); } @Override protected void onResume() { AlertDialog.Builder adb = new AlertDialog.Builder(this); LayoutInflater adbInflater = LayoutInflater.from(this); View eulaLayout = adbInflater.inflate(R.layout.checkbox, null); SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); String skipMessage = settings.getString("skipMessage", "NOT checked"); dontShowAgain = (CheckBox) eulaLayout.findViewById(R.id.skip); adb.setView(eulaLayout); adb.setTitle("PLEASE REGISTER THIS APPLICATION!"); adb.setMessage(Html.fromHtml("Please register this application in order to receive newer versions and support!")); adb.setPositiveButton("I understand", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String checkBoxResult = "NOT checked"; if (dontShowAgain.isChecked()) { checkBoxResult = "checked"; } SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putString("skipMessage", checkBoxResult); editor.commit(); // Do what you want to do on "OK" action return; } }); adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String checkBoxResult = "NOT checked"; if (dontShowAgain.isChecked()) { checkBoxResult = "checked"; } SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putString("skipMessage", checkBoxResult); editor.commit(); return; } }); if (!skipMessage.equals("checked")) { adb.show(); } super.onResume(); } public void clickedSettings(MenuItem item) { final int result = 1; Intent SettingsButtonClicked = new Intent (this, About.class); SettingsButtonClicked.putExtra("About", "MainActivity"); startActivityForResult(SettingsButtonClicked, result); } public void clickedSupercarSounds(View view) { final int result = 1; Intent SupercarSoundsButtonClicked = new Intent (this, ChooseManufacturer.class); SupercarSoundsButtonClicked.putExtra("Choose Manufacturer", "MainActivity"); startActivityForResult(SupercarSoundsButtonClicked, result); } public void clickedRegisterApplication(View view) { final int result = 1; Intent RegisterApplicationButtonClicked = new Intent (this, RegisterApplication.class); RegisterApplicationButtonClicked.putExtra("Register Application", "MainActivity"); startActivityForResult(RegisterApplicationButtonClicked, result); } } 

Thanks! 谢谢!

您需要将<activity>标签放置在AndroidManifest.xml的<application>标签中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:ActivityNotFoundException无法找到明确的活动类 - Android: ActivityNotFoundException Unable to find explicit activity class ActivityNotFoundException:无法找到显式活动类 - ActivityNotFoundException: Unable to find explicit activity class android.content.ActivityNotFoundException:无法找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class android.content.ActivityNotFoundException:无法在Android中找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class in Android ActivityNotFoundException:无法找到显式活动类GoogleDriveProxeyActivity是否已声明此内容 - ActivityNotFoundException: Unable to find explicit activity class GoogleDriveProxeyActivity have you declared this 对于服务类,我看到 android.content.ActivityNotFoundException: Unable to find explicit activity class - For a Service class I see android.content.ActivityNotFoundException: Unable to find explicit activity class android.content.ActivityNotFoundException:无法找到显式活动类; 您是否在 AndroidManifest.xml 中声明了此活动? - android.content.ActivityNotFoundException: Unable to find explicit activity class; have you declared this activity in your AndroidManifest.xml? android.content.ActivityNotFoundException:无法找到显式活动 class {您是否在 AndroidManifest.xml 中声明了此活动? - android.content.ActivityNotFoundException: Unable to find explicit activity class { have you declared this activity in your AndroidManifest.xml? ActivityNotFoundException:无法找到明确的活动类 {co.edu.unimagdalena.projecto/co.edu.unimagdalena.projecto.informacion2} - ActivityNotFoundException: Unable to find explicit activity class {co.edu.unimagdalena.projecto/co.edu.unimagdalena.projecto.informacion2} 无法找到显式活动类 - Unable to find explicit activity class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM