Brett Nottingham Brett Nottingham - 3 years ago 80
Android Question

How to programmatically launch a specific home page in android

I want to be able to launch a specific page of the home screen in my app, is there any way to do this?

Below is the typical method to launch the home screen, but I don't see anything about add a screen page or index value.

Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);

Answer Source

Not with the default Home screen.
Tucked away in the Launcher Activity source (at https://android.googlesource.com/platform/packages/apps/Launcher/+/master/src/com/android/launcher/Launcher.java#822) is this chunk of code (see line 822):

if (!mWorkspace.isDefaultScreenShowing()) {
    mWorkspace.moveToDefaultScreen();
}

So it is not possible to specify the specific page.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download