Programmatically launch default Android launcher and bring up application selection screen

StackOverflow https://stackoverflow.com/questions/20749935

  •  21-09-2022
  •  | 
  •  

Question

Ok, on the surface I thought this would be fairly easy to do but it's proving challenging for me. All I would like to do is programmatically start the default Android launcher and bring up the apps selection screen. By "apps selection screen" I mean the screen with all the devices applications that is often built into Android, often it can be seen by hitting an "apps" button on a device, the icon associated with the button is often a series of rectangles... I don't actually know what this activity/app is called... so I hope I am articulating this properly.

I know how to start the launcher, the intent I am using looks like this:

Intent().setComponent(new ComponentName("com.android.launcher", "com.android.launcher.Launcher"))

This can be used to start the launcher, however I don't know how to bring up the apps screen. I have looked at the logs using logcat and find that I see nothing to indicate an activity/package/application name when I press the apps button on my device(s). Would anyone be able to shed any light on this for me?

I've been Googling this for quite awhile and haven't found anything I can use, this admittedly could be because I don't know the name of the functionality I am trying to trigger, but for the life of me I can't find that either! . If anyone could point me in the right direction I would really appreciate it. Thanks much.

Was it helpful?

Solution

I know how to start the launcher, the intent I am using looks like this:

There is no guarantee that com.android.launcher exists on any Android device, let alone that it is "the default Android launcher" for the user's configuration.

Would anyone be able to shed any light on this for me?

There are dozens, perhaps hundreds, of launcher implementations that come preinstalled on devices. There are hundreds, perhaps thousands, of launcher implementations that users can download from places like the Play Store. None are required to provide any means for a third-party app to directly drive to "the apps screen". Heck, some will not even have an "apps screen".

You can see the source code to com.android.launcher here. This particular launcher is ancient, and there is no separate activity for the "apps screen", let alone one that is exported for third-party use. The same holds true for com.android.launcher2.

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