Question Detail

how to come on home screen in android programmatically?

5 years ago Views 1328 Visit Post Reply

I want to come on Mobile Home Screen By clicking on My Application Button it should redirect me on Android Home Screen in the Mobile. 

its like when we click on Home Softkey and it redirect us on the Home Screen. 

The same thing I want to do but I don't want to click on any soft key of mobile How can I do this?


Thread Reply

Hemant Sharma

- 5 years ago

You have to call your Launcher Application and you will be on Home Screen of the mobile 

try {
    Intent goHome = new Intent(Intent.ACTION_MAIN);
    goHome.addCategory(Intent.CATEGORY_HOME);
    goHome.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(goHome);
}catch (Exception e){
    Log.e("GOHOMEEXCEPTION", Log.getStackTraceString(e));
}
this.finish();

Enjoy!

Hemant Sharma

- 5 years ago

You have to call your Launcher Application and you will be on Home Screen of the mobile 

try {
    Intent goHome = new Intent(Intent.ACTION_MAIN);
    goHome.addCategory(Intent.CATEGORY_HOME);
    goHome.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(goHome);
}catch (Exception e){
    Log.e("GOHOMEEXCEPTION", Log.getStackTraceString(e));
}
this.finish();

Enjoy!