问题
I want to launch Home Screen From my application for that I used
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
I also follow this thread
Now I am having problem to launch in ICS(4.0). Problem is that I can't launch home screen while I am in some other application(to check this I created a thread in my app which will sleep for 5 sec and fires the intent so that I get time to go in some other app) it is working fine in 2.2 but failing on 4.0
Is this because of new architecture and way of handling activities in 4.0?
Logs are for 2.2 log
03-13 14:33:18.661: I/ActivityManager(73): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.examples.notifications/.NotificationsActivity }
03-13 14:33:19.161: I/ActivityManager(73): Displayed activity com.examples.notifications/.NotificationsActivity: 349 ms (total 349 ms)
03-13 13:39:23.601: I/ActivityManager(73): Starting activity: Intent { cmp=com.examples.notifications/.TransparentActivity }
03-13 13:39:23.981: I/ActivityManager(73): Displayed activity com.examples.notifications/.TransparentActivity: 368 ms (total 368 ms)
03-13 13:39:29.141: D/dalvikvm(150): GC_EXPLICIT freed 1355 objects / 84488 bytes in 116ms
03-13 13:39:30.834: D/home(317): navigating to home
03-13 13:39:30.851: I/ActivityManager(73): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.android.launcher/com.android.launcher2.Launcher }
03-13 13:39:30.941: W/InputManagerService(73): Ignoring hideSoftInput of: com.android.internal.view.IInputMethodClient$Stub$Proxy@451106e0
03-13 13:39:36.612: D/dalvikvm(317): GC_EXPLICIT freed 1704 objects / 109584 bytes in 108ms
For 4.0 ICS
03-13 13:43:02.343: I/ActivityManager(78): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.examples.notifications/.NotificationsActivity} from pid 188
03-13 13:43:02.343: W/WindowManager(78): Failure taking screenshot for (120x180) to layer 21010
03-13 13:43:02.393: W/NetworkManagementSocketTagger(78): setKernelCountSet(10040, 1) failed with errno -2
03-13 13:43:03.333: I/ActivityManager(78): Displayed com.examples.notifications/.NotificationsActivity: +946ms
03-13 13:43:03.602: W/InputManagerService(78): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@411d4098 (uid=10009 pid=188)
03-13 14:13:21.872: I/ActivityManager(78): START {cmp=com.examples.notifications/.TransparentActivity} from pid 557
03-13 14:13:21.872: W/WindowManager(78): Failure taking screenshot for (120x180) to layer 21015
03-13 14:13:22.012: V/PhoneStatusBar(143): setLightsOn(true)
03-13 14:13:22.502: D/dalvikvm(78): GC_CONCURRENT freed 499K, 11% free 8764K/9799K, paused 5ms+10ms
03-13 14:13:22.545: W/ThrottleService(78): unable to find stats for iface rmnet0
03-13 14:13:22.692: I/ActivityManager(78): Displayed com.examples.notifications/.TransparentActivity: +703ms
03-13 14:13:24.802: D/dalvikvm(143): GC_CONCURRENT freed 420K, 19% free 7121K/8775K, paused 15ms+7ms
03-13 14:13:25.812: W/WindowManager(78): Failure taking screenshot for (120x180) to layer 21025
03-13 14:13:26.192: V/PhoneStatusBar(143): setLightsOn(true)
03-13 14:13:26.361: W/ActivityManager(78): Activity pause timeout for ActivityRecord{4124ffb0 com.examples.notifications/.TransparentActivity}
03-13 14:13:26.373: W/NetworkManagementSocketTagger(78): setKernelCountSet(1000, 1) failed with errno -2
03-13 14:13:28.825: D/home(557): navigating to home
03-13 14:13:28.833: I/ActivityManager(78): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x400000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 557
03-13 14:13:28.864: W/NetworkManagementSocketTagger(78): setKernelCountSet(10040, 0) failed with errno -2
来源:https://stackoverflow.com/questions/9679677/can-not-launch-home-from-android-4-0