机器人:启用和服务 [英] android:enable and services

查看:119
本文介绍了机器人:启用和服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我米目前正在学习如何创建和Android上使用的服务。我看了看在Android SDK的进一步帮助,我找到了机器人:能= [真|假]

在SDK中说:

 的<用途>和<服务>属性必须都是真(因为它们都是由
默认)为服务被激活。如果任何一个是假的,该服务被禁用;
它不能被实例化。
 

所以,我想知道什么是利息/为什么(一般)

  • 设置应用程序使造假。
  • 设置服务能够为假。

我说,如果我们把服务使假是没有办法来调用该服务,那么为什么我们创建摆在首位的服务?

感谢你,对不起,这样长的消息。

解决方案

新SAF(存储访问架构)是采用Android的一个很好的例子:enabled属性。 <一href="http://developer.android.com/guide/topics/providers/document-provider.html">http://developer.android.com/guide/topics/providers/document-provider.html

  

安卓启用属性设置为一个布尔值的定义   资源文件。此属性的目的是禁用   供应商在运行Android 4.3或更低的设备。例如,

 安卓启用=@布尔/ atLeastKitKat
 

  

在除了包括本   在清单中的属性,你需要做到以下几点:   在根据RES /值的bool.xml资源文件/添加​​此行:

 &LT;布尔名=atLeastKitKat&GT;假&LT; /布尔&GT;
 

在根据RES /值-V19 /你bool.xml资源文件中,加入这一行:

 &LT;布尔名=atLeastKitKat&GT;真&LT; /布尔&GT;
 

I m currently learning how create and use services on android. I looked on the android SDK for further help and i found the android:enable=[true | false].

in the SDK is said that:

The <application> and <service> attributes must both be "true" (as they both are by
default) for the service to be enabled. If either is "false", the service is disabled;
it cannot be instantiated.

So i would like to know what is the interest of/ why (in general)

  • setting the application enables as "false".
  • setting the service enable as "false".

I say that if we put service enable as false there is no way to call that service, so why we create that service in the first place?

Thank you and sorry for such long message.

解决方案

New SAF(Storage Access Framework) is a good example of use of android:enabled attribute. http://developer.android.com/guide/topics/providers/document-provider.html

The android:enabled attribute set to a boolean value defined in a resource file. The purpose of this attribute is to disable the provider on devices running Android 4.3 or lower. For example,

android:enabled="@bool/atLeastKitKat" 

In addition to including this attribute in the manifest, you need to do the following: In your bool.xml resources file under res/values/, add this line:

<bool name="atLeastKitKat">false</bool> 

In your bool.xml resources file under res/values-v19/, add this line:

<bool name="atLeastKitKat">true</bool>

这篇关于机器人:启用和服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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