3

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
Community
  • 1
  • 1
Harshawardhan
  • 1,521
  • 1
  • 24
  • 29
  • add this : intent.setFlags(Intent.FLAG_FROM_BACKGROUND); – ρяσѕρєя K Mar 13 '12 at 07:18
  • can you paste the output when you invoke this code? – idiottiger Mar 13 '12 at 07:21
  • @imrankhan I tried that one too but not working on ics is it because of the different activity stack implementation ?i am confused. is there new activity stack supplementation for ics (as i dont return to my last activity when pressed back) – Harshawardhan Mar 13 '12 at 07:29
  • @idiottiger what ouptout are u refering to? – Harshawardhan Mar 13 '12 at 07:30
  • @devilcol the logcat output, has some warn or error message. – idiottiger Mar 13 '12 at 07:34
  • @idiottiger posted the logs in my question ! – Harshawardhan Mar 13 '12 at 08:58
  • I also observed that if new activity comes on foreground while my application is running and if i press back key then my application is not brought to foreground which means my application is not in app stack ? – Harshawardhan Mar 13 '12 at 09:26
  • from you logs `START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x400000 cmp=com.android.launcher/com.android.launcher2.Launcher}` system has called the Home, your ICS is the emulator or real device, if it's the emulator, when create the AVD , make the `Max VM application heap size` bigger, such as `48` or bigger. – idiottiger Mar 13 '12 at 09:29
  • @idiottiger i check Max vm size for emulator it is 48 and even though home is called by system for my device but home screen is not launched while some other app is in foreground but works fine when my app is in foreground. – Harshawardhan Mar 13 '12 at 09:51
  • `mHomeIntent = new Intent(Intent.ACTION_MAIN, null); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);` this is `PhoneWindowManager` init the `homeIntent` code, please try this, if it's not work, i cannot find another reason. – idiottiger Mar 13 '12 at 10:08
  • adding flag intent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TASK); solved my problem.. – Harshawardhan Mar 13 '12 at 12:04

0 Answers0