Question

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);
Was it helpful?

Solution

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.

OTHER TIPS

I'm not aware of a way to launch a specific "page" of the home screen. I wanted to answer this though because I think there's something you're not considering: a user might have a different app set as their home. For instance, I use the SlideScreen app as my home app, which does not have the different "pages" to it.

I would suggest looking for a different way to accomplish what you want, unless you're just going to use the app on your own device and don't feel that you're ever going to use a different app as your home.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top