为什么需要类别HOME? [英] Why is category HOME required?

查看:100
本文介绍了为什么需要类别HOME?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序清单文件中定义了以下类别:

I have these categories defined in my application manifest file:

<intent-filter>
   <action android:name="android.intent.action.MAIN" />
   <category android:name="android.intent.category.HOME"/>
   <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

如果我删除行-

<category android:name="android.intent.category.HOME"/>

它不影响应用程序功能的任何部分,我可以在Android设备的主屏幕启动器列表中看到我的应用程序.

It does not affect any part of the application functionality and I can see my application in the home screen launcher list of my android device.

但是,如果我删除了最后一行-

However, If I remove the last line -

<category android:name="android.intent.category.LAUNCHER" />

我看到我的应用程序从我的android设备的主屏幕启动器列表中消失的更改.

I see the change that my application gets disappeared from home screen launcher list of my android device.

所以我的问题是该类别HOME的目的是什么,它的通常用途是什么.

So my question is what's the purpose of this category HOME and what's its common use.

如果该类别的唯一目的是启动主屏幕,如 android文档中所述,那么我也可以通过以下方式做到这一点:

If the only purpose of this category is to launch the home screen as mentioned in the android docs, then this I can do by the following also:

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

推荐答案

 <category android:name="android.intent.category.HOME"/>

表示,当您按下主屏幕按钮时,您的应用将被列为启动启动器主屏幕或主屏幕活动的选项(以及所有在活动清单中具有此类别的应用程序).为简单起见,每当您按下主屏幕按钮时,手机中安装的所有应用程序(在AndroidManifest.xml中的intent-filter中具有CATEGORY.HOME类别和Action_Main的所有应用程序都将列出)(除非您选择了某些应用程序作为默认设置).一个选择器,供用户选择要启动的房屋.

indicates that when you press home button, your app will be listed as an option to launch the launcher home or your home activity (along with all the applications which have this category in their manifest for an activity). To be more simple, whenever you press the home button, all the applications installed in your phone which have CATEGORY.HOME category and Action_Main in intent-filter in their AndroidManifest.xml will be listed (unless you have chosen some application as default) in a chooser for the user to select which HOME they want to launch.

这篇关于为什么需要类别HOME?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆