I am working on a tablet that will not feature all the navigation buttons, just powerup, so I need a way to go from an activity to show the home screen. What Intent action can i fire that is guaranteed to show clear homescreen? What intent\action fires when you click on the device button that takes you to homescreen. Thanks?
Asked
Active
Viewed 264 times
3 Answers
0
just call the following code from any activity:
moveTaskToBack(true);
You may want to add a button of some sort to invoke this function. Good luck

PowerAktar
- 2,341
- 1
- 21
- 17
-
so just context.moveTaskToBack(true) Is that what the button acctually does. – Androider Mar 26 '11 at 03:01
0
You could try and finish() all of your activities. Maybe in Application keep a ivar that is showHome, if true on resume() in each activity just call finish(). This is not really standard android behavior though.
Edit** If you want to fire their launcher you can checkout this thread: Going to home screen programmatically
-
ok. but in android if you push a certain button you always get back to home screen. What Intent is this sending out? – Androider Mar 26 '11 at 02:59
0
Untested Code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setClassName("myPackage","myPackage.MyClass");
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
try {
startActivity(intent);
}
catch (Exception e)
{
Log.d(TAG,"myMethod",e);
}

JAL
- 3,319
- 2
- 20
- 17