在Android清单使用CATEGORY_HOME的目的是什么? [英] Purpose of using CATEGORY_HOME in android manifest?

查看:8296
本文介绍了在Android清单使用CATEGORY_HOME的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是替代去除AndroidManifest如下:

 <活动

    机器人:名称=com.apper.main.UserActivity
    机器人:标签=@字符串/ APP_NAME
    机器人:launchMode =singleTask
    机器人:clearTaskOnLaunch =真
    机器人:stateNotNeeded =真正的>
        <意向滤光器>
            <作用机器人:名称=android.intent.action.MAIN/>
            <类机器人:名称=android.intent.category.HOME/>
            <类机器人:名称=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
 < /活性GT;
 

我还发现,删除上述行之后,并没有影响到我的Andr​​oid 应用。什么是主要使用这一类的,什么是替代它。

如果这一类的意图是发射主屏幕那么它可以通过以下来完成:

 意图homeIntent =新的意图(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(homeIntent);
 

这上面的code将启动主屏幕,但为什么在Android清单行了? 有什么目的,从这里取出该行并没有改变应用程序?

解决方案
  

什么是主要使用这一类的

据,加上 ACTION_MAIN ,标识更换主屏幕。

  

有什么替代它

没有它。要么你有这个类别,或者你没有。

What is the alternative to removing the following from AndroidManifest:

 <activity           

    android:name="com.apper.main.UserActivity"
    android:label="@string/app_name"        
    android:launchMode="singleTask"
    android:clearTaskOnLaunch="true"
    android:stateNotNeeded="true" >
        <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>
 </activity>

I also found that after removing the above line, there was no impact to my android application. What's the main use of this category and what's the alternative to it.

If the intent of this category is to launch the home screen then it can be done by the following:

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

This above code will launch the home screen but why the line in the android manifest ? What's the purpose as removing the line from here does nothing change the application ?

解决方案

What's the main use of this category

It, coupled with ACTION_MAIN, identifies a replacement home screen.

what's the alternative to it

Not having it. Either you have this category, or you do not.

这篇关于在Android清单使用CATEGORY_HOME的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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