为什么活动/服务需要显式地添加到Android清单? [英] Why do Activities/Services need to be explicitly added to the Android manifest?

查看:160
本文介绍了为什么活动/服务需要显式地添加到Android清单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的发展,你必须所有的活动和/或服务添加到清单文件。我知道如何做到这一点,但我不明白的为什么我需要这样做。这似乎是一个不必要的箍跳通过。

In Android development, you have to add all Activities and/or Services to the manifest file. I understand how to do this, but I don't understand why I need to do this. It seems like an unnecessary hoop to jump through.

在Android的帮助文档,但我仍然不清楚为什么(的 http://developer.android.com/guide/topics/manifest/manifest-intro.html )。

The Android documentation helps, but I'm still not clear on "why" (http://developer.android.com/guide/topics/manifest/manifest-intro.html).

推荐答案

我可以回答至少有一部分的为什么作为活动。

I can answer at least part of the why for Activities.

该清单也是你声明你的IntentFilter这是系统如何理解你的应用程序的功能。即如果你的活动是,当用户试图拍摄一张照片难以辨认的选择吗?选择一个文件?分享一段文字?此外,该IntentFilter的也告诉了启动应用程序,你想有你的活动包括在应用程序的抽屉里。

The manifest is also where you declare your IntentFilter which is how the system understands what your application does. i.e. should your activity be an illegible choice when the user is trying to take a picture? choose a file? share a piece of text? In addition to that the IntentFilter also tells the Launcher application that you would like to have your activity included in the Applications drawer.

还有,你可以在其上必须在清单即SingleTop完成活动设置多个配置选项。如果没有在清单申报就没有地方申报这些配置。

There are also several configuration options that you can set on Activities which have to be done in the manifest i.e. SingleTop. Without the declaration in the manifest there would be no place to declare these configurations.

这篇关于为什么活动/服务需要显式地添加到Android清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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