How to launch the home on Android?

1

If I am in my application and sent the user to his configuration with this.

startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS), 0);

But how can I send the user to the home of his phone, not return it to the application.

Since to return it to the application is with this

Intent LaunchIntent = new Intent(context,Home.class);
LaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(LaunchIntent);
    
asked by JDeveloper 30.06.2016 в 00:50
source

2 answers

2

If you want to simulate that the user has clicked "Home" and that your app is hidden but working, you can do something like this:

public static void pulsarBotonHome(Context context){
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
    
answered by 03.07.2016 в 20:29
0

If by saying "home of the phone" you mean the desktop, if you are in the main Activity, it simply ends after performing the intent with a finish()

Example:

startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS), 0);
finish();
    
answered by 30.06.2016 в 04:32