如何以编程方式在android中启动特定主页
我希望能够在我的应用程序中启动主屏幕的特定页面,有什么办法可以做到这一点?
以下是启动主屏幕的典型方法,但我没有看到任何有关添加屏幕页面或索引值的信息。
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不适用于默认主屏幕。
隐藏在
Launcher
Activity 源中(位于 https://android.googlesource.com/platform/packages/apps/Launcher/+/master/src/com/android/launcher/Launcher.java#822< /a>) 是这段代码(参见第 822 行):因此不可能指定特定页面。
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):So it is not possible to specify the specific page.
我不知道如何启动主屏幕的特定“页面”。我想回答这个问题,因为我认为有些事情你没有考虑:用户可能将不同的应用程序设置为他们的家。例如,我使用 SlideScreen 应用程序作为我的家庭应用程序,它没有不同的“页面”。
我建议寻找一种不同的方式来完成你想要的事情,除非你只是要在自己的设备上使用该应用程序并且不觉得你会在家里使用不同的应用程序。
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.