Why am I getting error suspended ActivityNotFoundException?
package com.basic.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class androidbasics extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread logoTimer = new Thread(){
public void run(){
try{
int logoTimer=0;
while(logoTimer<5000){
sleep(500);
logoTimer = logoTimer +100;
}
startActivity(new Intent("com.basic.android.MENU"));
}catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
finish();
}
}
};
logoTimer.start();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.basic.android"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".androidbasics"
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=".menu"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.basic.android.MENU" />
<category android:name="android.inte开发者_StackOverflow中文版nt.category.DEFALT" />
</intent-filter>
</activity>
<activity android:name=".DisplayOne"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.basic.android.DISPLAYONE" />
<category android:name="android.intent.category.DEFALT" />
</intent-filter>
</activity>
<activity android:name=".TutorialTwo"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.basic.android.TUTORIALTWO" />
<category android:name="android.intent.category.DEFALT" />
</intent-filter>
</activity>
<activity android:name=".Sweet"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog"
>
<intent-filter>
<action android:name="com.basic.android.SWEET" />
<category android:name="android.intent.category.DEFALT" />
</intent-filter>
</activity>
<activity android:name=".TutorialFour"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="com.basic.android.TUTORIALFOUR" />
<category android:name="android.intent.category.DEFALT" />
</intent-filter>
</activity>
<activity android:name=".TutorialThree"
android:label="@string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="com.basic.android.TUTORIALTHREE" />
<category android:name="android.intent.category.DEFALT" />
</intent-filter>
</activity>
</application>
</manifest>
Errors:
06-29 11:57:56.356: ERROR/Zygote(32): setreuid() failed. errno: 2
06-29 11:58:11.466: ERROR/Zygote(32): setreuid() failed. errno: 17
06-29 11:58:15.035: ERROR/BatteryService(67): usbOnlinePath not found
06-29 11:58:15.035: ERROR/BatteryService(67): batteryVoltagePath not found
06-29 11:58:15.045: ERROR/BatteryService(67): batteryTemperaturePath not found
06-29 11:58:15.125: ERROR/SurfaceFlinger(67): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
06-29 11:58:30.165: ERROR/EventHub(67): could not get driver version for /dev/input/mouse0, Not a typewriter
06-29 11:58:30.165: ERROR/EventHub(67): could not get driver version for /dev/input/mice, Not a typewriter
06-29 11:58:30.595: ERROR/System(67): Failure starting core service
06-29 11:58:30.595: ERROR/System(67): java.lang.SecurityException
06-29 11:58:30.595: ERROR/System(67): at android.os.BinderProxy.transact(Native Method)
06-29 11:58:30.595: ERROR/System(67): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
06-29 11:58:30.595: ERROR/System(67): at android.os.ServiceManager.addService(ServiceManager.java:72)
06-29 11:58:30.595: ERROR/System(67): at com.android.server.ServerThread.run(SystemServer.java:184)
06-29 11:58:33.846: ERROR/SoundPool(67): error loading /system/media/audio/ui/Effect_Tick.ogg
06-29 11:58:33.866: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressStandard.ogg
06-29 11:58:33.896: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressSpacebar.ogg
06-29 11:58:33.935: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressDelete.ogg
06-29 11:58:33.946: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressReturn.ogg
06-29 11:58:42.016: ERROR/ThrottleService(67): Could not open GPS configuration file /etc/gps.conf
06-29 11:58:44.726: ERROR/logwrapper(141): executing /system/bin/tc failed: No such file or directory
06-29 11:58:44.826: ERROR/logwrapper(142): executing /system/bin/tc failed: No such file or directory
06-29 11:58:44.925: ERROR/logwrapper(144): executing /system/bin/tc failed: No such file or directory
06-29 11:58:58.785: ERROR/ActivityManager(67): ANR in com.android.settings
06-29 11:58:58.785: ERROR/ActivityManager(67): Reason: Broadcast of Intent { act=android.intent.action.CLOSE_SYSTEM_DIALOGS cmp=com.android.settings/.widget.SettingsAppWidgetProvider (has extras) }
06-29 11:58:58.785: ERROR/ActivityManager(67): Load: 2.74 / 0.7 / 0.23
06-29 11:58:58.785: ERROR/ActivityManager(67): CPU usage from 17983ms to 1294ms ago:
06-29 11:58:58.785: ERROR/ActivityManager(67): system_server: 34% = 20% user + 13% kernel / faults: 7292 minor 16 major
06-29 11:58:58.785: ERROR/ActivityManager(67): adbd: 18% = 1% user + 17% kernel / faults: 11 minor
06-29 11:58:58.785: ERROR/ActivityManager(67): bootanimation: 7% = 5% user + 1% kernel / faults: 517 minor
06-29 11:58:58.785: ERROR/ActivityManager(67): zygote: 0% = 0% user + 0% kernel / faults: 82 minor
06-29 11:58:58.785: ERROR/ActivityManager(67): kswapd0: 0% = 0% user + 0% kernel
06-29 11:58:58.785: ERROR/ActivityManager(67): netd: 0% = 0% user + 0% kernel / faults: 21 minor
06-29 11:58:58.785: ERROR/ActivityManager(67): logcat: 0% = 0% user + 0% kernel / faults: 49 minor
06-29 11:58:58.785: ERROR/ActivityManager(67): events/0: 0% = 0% user + 0% kernel
06-29 11:58:58.785: ERROR/ActivityManager(67): servicemanager: 0% = 0% user + 0% kernel / faults: 10 minor
06-29 11:58:58.785: ERROR/ActivityManager(67): qemud: 0% = 0% user + 0% kernel / faults: 33 minor
06-29 11:58:58.785: ERROR/ActivityManager(67): +ronsoft.openwnn: 0% = 0% user + 0% kernel
06-29 11:58:58.785: ERROR/ActivityManager(67): +m.android.phone: 0% = 0% user + 0% kernel
06-29 11:58:58.785: ERROR/ActivityManager(67): +ndroid.launcher: 0% = 0% user + 0% kernel
06-29 11:58:58.785: ERROR/ActivityManager(67): +ndroid.settings: 0% = 0% user + 0% kernel
06-29 11:58:58.785: ERROR/ActivityManager(67): TOTAL: 100% = 47% user + 48% kernel + 1% irq + 2% softirq
06-29 11:59:37.867: ERROR/HierarchicalStateMachine(67): TetherMaster - unhandledMessage: msg.what=3
change..(see DEFALT change to DEFAULT in category)
The issue was in mismatch in defining activity name.
In manifest you have defined the activity name is menu
not MENU
<activity android:name=".menu"
android:label="@string/app_name">
But in code startActivity(new Intent("com.basic.android.MENU"));
you want to start an activity MENU whcich is not defined because in manifest menu is defined but MENU is not defined
The activity name is case sensitive
Before calling startActivity(new Intent("com.basic.android.MENU")) cancel your logoTimer
like
logoTimer.cancel();
startActivity(new Intent("com.basic.android.MENU"))
//
public void toCallActivity() {
TimerTask startNewActivity;
final Handler handler = new Handler();
Timer timer = new Timer();
startNewActivity = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
handler.post(new Runnable() {
public void run() {
try {
timer.cancel();
startActivity(new Intent("com.basic.android.MENU"));
} catch (Exception e) {
// TODO Auto-generated catch block
}
}
});
}
};
timer.schedule(startNewActity, 0,5000);
}
The issue was in mismatch in defining activity name. In manifest you have defined the activity name is menu not MENU
<activity android:name=".menu"
android:label="@string/app_name">
Android Studio is case sensitive, so this should work.
精彩评论