当前位置:  编程技术>移动开发
本页文章导读:
    ▪查看Battery剩下电量        查看Battery剩余电量   private int intLevel; private int intScale; private Button mButton01; private AlertDialog d; private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent int.........
    ▪ 【通译】(74)动画        【翻译】(74)动画 【翻译】(74)动画   see http://developer.android.com/guide/topics/graphics/animation.html   原文见 http://developer.android.com/guide/topics/graphics/animation.html   -------------------------------   Animation   .........
    ▪ 【通译】(56)path-permission元素       【翻译】(56)path-permission元素 【翻译】(56)path-permission元素   see http://developer.android.com/guide/topics/manifest/path-permission-element.html   原文见 http://developer.android.com/guide/topics/manifest/path-permission-elemen.........

[1]查看Battery剩下电量
    来源: 互联网  发布时间: 2014-02-18
查看Battery剩余电量

 

private int intLevel;
	private int intScale;
	private Button mButton01;
	private AlertDialog d;

	private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver() {
		public void onReceive(Context context, Intent intent) {
			String action = intent.getAction();
			/*
			 * 如果捕捉到的action是ACTION_BATTERY_CHANGED, 就执行onBatteryInfoReceiver()
			 */
			if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
				intLevel = intent.getIntExtra("level", 0);
				intScale = intent.getIntExtra("scale", 100);
				onBatteryInfoReceiver(intLevel, intScale);
			}
		}
	};

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_battery);

		/* 初始化Button,并设定按下后的操作 */
		mButton01 = (Button) findViewById(R.id.myButton1);
		mButton01.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v) {
				/* 注册几个系统 BroadcastReceiver,作为访问电池计量之用 */
				registerReceiver(mBatInfoReceiver, new IntentFilter(
						Intent.ACTION_BATTERY_CHANGED));
			}
		});
	}

	/* 拦截到ACTION_BATTERY_CHANGED时要执行的method */
	public void onBatteryInfoReceiver(int intLevel, int intScale) {
		/* create 弹出的对话窗口 */
		d = new AlertDialog.Builder(MyBattery.this).create();
		d.setTitle("系统信息");
		/* 将取得的电吕计量显示于Dialog中 */
		d.setMessage("剩余电池量"
				+ String.valueOf(intLevel * 100 / intScale) + "%");
		/* 设定返并加画面的按钮 */
		d.setButton("确定",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						/* 反注册Receiver,并关闭对话窗口 */
						unregisterReceiver(mBatInfoReceiver);
						d.dismiss();
					}
				});
		d.show();
	}
 


 

    
[2] 【通译】(74)动画
    来源: 互联网  发布时间: 2014-02-18
【翻译】(74)动画

【翻译】(74)动画

 

see

http://developer.android.com/guide/topics/graphics/animation.html

 

原文见

http://developer.android.com/guide/topics/graphics/animation.html

 

-------------------------------

 

Animation

 

动画

 

-------------------------------

 

See also

 

另见

 

Property Animation 属性动画

View Animation 视图动画

Drawable Animation 可绘画对象动画

 

-------------------------------

 

The Android framework provides two animation systems: property animation (introduced in Android 3.0) and view animation. Both animation systems are viable options, but the property animation system, in general, is the preferred method to use, because it is more flexible and offers more features. In addition to these two systems, you can utilize Drawable animation, which allows you to load drawable resources and display them one frame after another.

 

Android框架提供两个动画系统:属性动画(在Android 3.0中引入)(注:github上有向后移植版,可以兼容2.1+,见https://github.com/laanwj/android-animation-backport)以及视图动画。两个动画系统都是可行的选择,但通常属性动画系统是首选的使用方法,因为它更灵活而且提供更多特性。在这两个系统之外,你可以利用Drawable动画,它允许你加载可绘画资源并且一帧接一帧地显示它们。

 

The view animation system provides the capability to only animate View objects, so if you wanted to animate non-View objects, you have to implement your own code to do so. The view animation system is also constrained in the fact that it only exposes a few aspects of a View object to animate, such as the scaling and rotation of a View but not the background color, for instance.

 

视图动画系统只提供动画化View对象的功能,所以如果你希望动画化非View对象,你不得不实现你自己的代码来做到这点。视图动画系统还被限制这样的事实,它只暴露一个要动画化的View对象的少量方面,诸如一个View的缩放和旋转,但背景颜色之类的则不能。

 

Another disadvantage of the view animation system is that it only modified where the View was drawn, and not the actual View itself. For instance, if you animated a button to move across the screen, the button draws correctly, but the actual location where you can click the button does not change, so you have to implement your own logic to handle this.

 

视图动画系统的另一个缺点是它只修改View被绘画在的地方,而不是实际View自身。例如,如果你动画化一个按钮以跨屏幕移动,那么按钮正确地绘画,但你可以点击按钮的实际位置并没有改变,所以你不得不实现你自己的逻辑以处理它。

 

With the property animation system, these constraints are completely removed, and you can animate any property of any object (Views and non-Views) and the object itself is actually modified. The property animation system is also more robust in the way it carries out animation. At a high level, you assign animators to the properties that you want to animate, such as color, position, or size and can define aspects of the animation such as interpolation and synchronization of multiple animators.

 

使用属性动画系统,这些限制被完全地移除,并且你可以动画化任意对象(View和非View)的任意属性而对象自身被实际地修改。属性动画系统也通过它解决动画的方式是变得更强壮。在更高的层面上,你赋予动画器到你希望动画化的属性,诸如颜色、位置、或大小,而且可以定义动画的切面诸如多动画器的插值和同步。

 

The view animation system, however, takes less time to setup and requires less code to write. If view animation accomplishes everything that you need to do, or if your existing code already works the way you want, there is no need to use the property animation system. It also might make sense to use both animation systems for different situations if the use case arises.

 

然而,视图动画系统花费更少的时间配置并且需要写较少的代码。如果视图动画实现你需要做的每一件事情,或者如果你的现存代码已经如你所愿地工作,那么没有必要使用属性动画系统。对不同的情形使用两种动画系统还可能有意义,如果该用例(注:用例是软件工程术语,指用非技术用语来描述用户的使用场景)出现。

 

Property Animation

 

属性动画

 

Introduced in Android 3.0 (API level 11), the property animation system lets you animate properties of any object, including ones that are not rendered to the screen. The system is extensible and lets you animate properties of custom types as well.

 

在Android 3.0(API级别11)中引入。属性动画系统让你动画化任意对象的属性,包括那些不被渲染到屏幕的对象。系统是可扩展的,也可以让你动画化自定义类型的属性。

 

View Animation

 

视图动画

 

View Animation is the older system and can only be used for Views. It is relatively easy to setup and offers enough capabilities to meet many application's needs.

 

视图动画是较旧的系统,只可以被用于View。它相对容易配置并且提供足够的能力来满足许多应用程序的需要。

 

Drawable Animation

 

可绘画对象动画

 

Drawable animation involves displaying Drawable resources one after another, like a roll of film. This method of animation is useful if you want to animate things that are easier to represent with Drawable resources, such as a progression of bitmaps.

 

可绘画对象动画一个接一个地调用正在显示的Drawable资源,就像一个滚动的胶卷(注:电影)。这种方法的动画是有用的,如果你希望动画化一些东西,它们较容易用Drawable资源呈现,诸如一些连续的位图。

 

Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.

 

除特别说明外,本文在Apache 2.0下许可。细节和限制请参考内容许可证。

 

Android 4.0 r1 - 08 Mar 2012 0:34

 

-------------------------------

 

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

 

(此页部分内容基于Android开源项目,以及使用根据创作公共2.5来源许可证描述的条款进行修改)

 

(本人翻译质量欠佳,请以官方最新内容为准,或者参考其它翻译版本:

* ソフトウェア技術ドキュメントを勝手に翻訳

http://www.techdoctranslator.com/android

* Ley's Blog

http://leybreeze.com/blog/

* 农民伯伯

http://www.cnblogs.com/over140/

* Android中文翻译组

http://androidbox.sinaapp.com/



    
[3] 【通译】(56)path-permission元素
    来源: 互联网  发布时间: 2014-02-18
【翻译】(56)path-permission元素

【翻译】(56)path-permission元素

 

see

http://developer.android.com/guide/topics/manifest/path-permission-element.html

 

原文见

http://developer.android.com/guide/topics/manifest/path-permission-element.html

 

-------------------------------

 

<path-permission>

 

path-permission元素

 

-------------------------------

 

* syntax:

 

* 语法:

 

-------------------------------

 

<path-permission android:path="string"

                 android:pathPrefix="string"

                 android:pathPattern="string"

                 android:permission="string"

                 android:readPermission="string"

                 android:writePermission="string" />

 

-------------------------------

 

* contained in:

 

* 被包含在:

 

<provider>

 

* description:

 

* 描述:

 

Defines the path and required permissions for a specific subset of data within a content provider. This element can be specified multiple times to supply multiple paths.

 

定义在一个内容提供者中特定数据子集的路径和所需的权限。这个元素可以被指定多次以提供多个路径。

 

* attributes:

 

* 属性:

 

* android:path

 

A complete URI path for a subset of content provider data. Permission can be granted only to the particular data identified by this path. When used to provide search suggestion content, it must be appended with "/search_suggest_query".

 

内容提供者数据的子集的完整URI路径。权限可以被授权只对应被这个路径标识的特殊数据。当用于提供搜索建议的内容时,它必须用"/search_suggest_query"尾加。

 

* android:pathPrefix

 

The initial part of a URI path for a subset of content provider data. Permission can be granted to all data subsets with paths that share this initial part.

 

用于内容提供者数据的子集的URI的开头部分。权限可以被授权给所有带有共享此开头部分的路径的数据子集。

 

* android:pathPattern

 

A complete URI path for a subset of content provider data, but one that can use the following wildcards:

 

用于内容提供者数据的子集的完整URI路径,但它可以使用以下通配符:

 

* An asterisk ('*'). This matches a sequence of 0 to many occurrences of the immediately preceding character.

 

* 一个星号('*')匹配一个零到多次出现的即时(注:紧接)前驱字符的序列。

 

* A period followed by an asterisk (".*"). This matches any sequence of 0 or more characters.

 

* 一个点后面跟着一个星号(".*")匹配0到多个字符的任意序列。

 

Because '\' is used as an escape character when the string is read from XML (before it is parsed as a pattern), you will need to double-escape. For example, a literal '*' would be written as "\\*" and a literal '\' would be written as "\\". This is basically the same as what you would need to write if constructing the string in Java code.

 

因为'\'被用作一个转义字符当该字符串从XML中被读取(在它被解释为一个模式之前),你将需要双转义:例如,一个字面'*'应该被写成"\\*"而一个字面'\'应该被写成"\\\\"。这基本上和如果在Java代码中构造字符串的话你需要写的东西是相同的。

 

For more information on these types of patterns, see the descriptions of PATTERN_LITERAL, PATTERN_PREFIX, and PATTERN_SIMPLE_GLOB in the PatternMatcher class.

 

想获得关于这三种类型模式的更多信息,参见PatternMatcher类中PATTERN_LITERAL,PATTERN_PREFIX,和PATTERN_SIMPLE_GLOB的描述。

 

* android:permission

 

The name of a permission that clients must have in order to read or write the content provider's data. This attribute is a convenient way of setting a single permission for both reading and writing. However, the readPermission and writePermission attributes take precedence over this one.

 

权限的名称,客户端必须拥有该权限以便读取或写入内容提供者的数据。这个属性是设置单一权限用于读写的便利方法。然而,readPermission和writePermission属性持有比它高的优先级。

 

* android:readPermission

 

A permission that clients must have in order to query the content provider.

 

客户端必须拥有的权限以便查询内容提供者。

 

* android:writePermission

 

A permission that clients must have in order to make changes to the data controlled by the content provider.

 

客户端必须拥有的权限以便对内容提供者控制的数据作出改变。

 

* introduced in:

 

* 引入:

 

API Level 4

 

API级别4

 

* see also:

 

* 另见:

 

SearchManager

Manifest.permission

Security and Permissions 安全与权限

 

Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.

 

除特别说明外,本文在Apache 2.0下许可。细节和限制请参考内容许可证。

 

Android 4.0 r1 - 10 Feb 2012 0:44

 

-------------------------------

 

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

 

(此页部分内容基于Android开源项目,以及使用根据创作公共2.5来源许可证描述的条款进行修改)

 

(本人翻译质量欠佳,请以官方最新内容为准,或者参考其它翻译版本:

* ソフトウェア技術ドキュメントを勝手に翻訳

http://www.techdoctranslator.com/android

* Ley's Blog

http://leybreeze.com/blog/

* 农民伯伯

http://www.cnblogs.com/over140/

* Android中文翻译组

http://androidbox.sinaapp.com/



    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
javascript开源软件 iis7站长之家
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3