我想从我的应用程序中启动主屏幕
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
我也遵循这个thread
现在我在ICS(4.0)中启动时遇到问题。问题是,当我在其他应用程序中时,我无法启动主屏幕(为了检查这一点,我在我的应用程序中创建了一个线程,它将睡眠5秒并触发意图,以便我有时间进入其他应用程序)它在2.2中正常工作但在4.0上失败
这是因为新的架构和4.0中处理活动的方式吗?
日志是 为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
适用于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