- 浏览: 5778138 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (890)
- WindowsPhone (0)
- android (88)
- android快速迭代 (17)
- android基础 (34)
- android进阶 (172)
- android高级 (0)
- android拾遗 (85)
- android动画&效果 (68)
- Material Design (13)
- LUA (5)
- j2me (32)
- jQuery (39)
- spring (26)
- hibernate (20)
- struts (26)
- tomcat (9)
- javascript+css+html (62)
- jsp+servlet+javabean (14)
- java (37)
- velocity+FCKeditor (13)
- linux+批处理 (9)
- mysql (19)
- MyEclipse (9)
- ajax (7)
- wap (8)
- j2ee+apache (24)
- 其他 (13)
- phonegap (35)
最新评论
-
Memories_NC:
本地lua脚本终于执行成功了,虽然不是通过redis
java中调用lua脚本语言1 -
ZHOU452840622:
大神://处理返回的接收状态 这个好像没有监听到 遇 ...
android 发送短信的两种方式 -
PXY:
拦截部分地址,怎么写的for(int i=0;i<lis ...
判断是否登录的拦截器SessionFilter -
maotou1988:
Android控件之带清空按钮(功能)的AutoComplet ...
自定义AutoCompleteTextView -
yangmaolinpl:
希望有表例子更好。。。,不过也看明白了。
浅谈onInterceptTouchEvent、onTouchEvent与onTouch
import android.app.Activity; import android.app.Dialog; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.TextView; public class BatteryInfo extends Activity { /* 变量声明 */ private int intLevel; private int intScale; private Button mButton01; /* 创建BroadcastReceiver */ 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); Log.i("", "intLevel = " + intLevel); Log.i("", "intScale = " + intScale); onBatteryInfoReceiver(intLevel, intScale); } } }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mButton01 = (Button) findViewById(R.id.myButton1); mButton01.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { // 注册一个系统 BroadcastReceiver,作为访问电池计量之用 // 這個不能直接在AndroidManifest.xml中註冊 registerReceiver(mBatInfoReceiver, new IntentFilter( Intent.ACTION_BATTERY_CHANGED)); } }); } /* 捕捉到ACTION_BATTERY_CHANGED时要运行的method */ public void onBatteryInfoReceiver(int intLevel, int intScale) { /* create 跳出的对话窗口 */ final Dialog d = new Dialog(BatteryInfo.this); d.setTitle(R.string.str_dialog_title); d.setContentView(R.layout.mydialog); /* 创建一个背景模糊的Window,且将对话窗口放在前景 */ Window window = d.getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); /* 将取得的电池计量显示于Dialog中 */ TextView mTextView02 = (TextView) d.findViewById(R.id.myTextView2); mTextView02.setText(getResources() .getText(R.string.str_dialog_body) + String.valueOf(intLevel * 100 / intScale) + "%"); /* 设置返回主画面的按钮 */ Button mButton02 = (Button) d.findViewById(R.id.myButton2); mButton02.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { /* 反注册Receiver,并关闭对话窗口 */ unregisterReceiver(mBatInfoReceiver); d.dismiss(); } }); d.show(); } }
代码里还用到了自定义的Dialog布局:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/white" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/myTextView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="@drawable/blue" android:textSize="16sp" android:gravity="center" android:padding="10px"> </TextView> <Button android:id="@+id/myButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_button2"> </Button> </LinearLayout>
http://edison-cool911.iteye.com/blog/737781
发表评论
-
http://www.android-studio.org/
2018-08-06 09:25 0http://www.android-studio.org/ ... -
SlidingDrawer源码
2012-03-14 10:13 3776我把SlidingDrawer源码提了出来,希望对1.5的朋友 ... -
简单拖动效果(带Cache,需要完善)
2011-10-13 15:10 4183如何去实现一个具有幻象的拖拽效果? 所谓”幻象“就是当你按下去 ... -
Android Activity中启动另一应用程序的方法,无需得到类名
2011-08-02 14:46 17200在网上搜索了一会相关的实现代码,发现所有的文章都说是需要包名和 ... -
java-universal-tween-engine,一个动画系统库
2011-06-29 09:21 6700http://code.google.com/p/java-u ... -
网上发现的一个android UI包
2011-05-24 12:21 4050里面有些UI和效果 -
android中使用代码启动其他程序
2011-04-29 23:15 5223你要訪問其他的程序,那麼這個程序要先裝載到模擬器或真機上面,因 ... -
listView背景问题以及限制editText字数以及如果想通知别人已经不能在写
2011-04-29 22:44 31621.在listView设置好背景之后 你如果点击空白出 你会发 ... -
Android键盘和触摸事件处理
2011-04-29 22:32 6965activity和VIEW都能接收触摸和按键,如果响应事件只需 ... -
Android的绘制文本对象FontMetrics的介绍及绘制文本
2011-04-29 22:29 11463一。Android绘制文本对象FontMetrics介绍 ... -
Android View 拖动&插入
2011-04-29 22:20 3507View 拖动&插入 即: 支持 拖动图标 然后 ... -
使TextView文本可以水平和垂直滚动
2011-04-29 21:59 14340在做一个小的电子书程序,要求电子书具有放大缩小的功能,所以肯定 ... -
ArrayAdapter源码
2011-04-29 12:29 6265看看人家怎么写的。 /* * Copyright (C ... -
Android下获取开机时间
2011-04-02 21:51 6186找了一圈没发现能得到开机启动时间资料,于是乎突发奇想,得到了解 ... -
AutoCompleteTextView连接到数据库
2011-03-30 20:49 4656AutoCompleteTextView可以根据输入 ... -
改变屏幕Brightness(亮度)
2011-03-30 12:48 4567http://www.eoeandroid.com/forum ... -
android 拖拽图片&拖动浮动按钮到处跑
2011-02-24 20:55 31706来自老外: import android.app.Acti ... -
拖动一个控件在另一个控件(layout)上,并固定位置在几个位置显示
2011-02-24 20:51 5852实现效果: 鼠标拖动btn SSS,SSS在水平的layo ... -
Handler与Message类,实现n秒后无操作自动消失功能
2011-02-24 20:45 4595实现功能:某控件不操作10秒后,自动消失。如照相机变焦条出现后 ... -
带删除按钮的ListView
2011-02-24 10:33 6114不用说了,上图先: import java.util.A ...
相关推荐
主要介绍了Android获取手机电池电量用法,以完整实例形式较为详细的分析了Android获取手机电量的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
【Android】获取电池电量 Demo
Android 获取手机当前电量, int level;定义的是当前电池电量,int scale;定义的是手机总电量。注册访问电池剩余量的系统BroadcastReceiver,当前手机电量为:" level*100/scale "%,这个计算方法相信大家都会吧。
一个安卓获取手机电量使用明细的小例子源码,手机中各个应用的耗电信息,真机通过文件计算,虚拟机通过计算CUP利用时间显示每个程序对电量的使用百分比。
实现一个电池属性实时监听器。这些属性包括温度,电池电量....等等。而且,使用Service,Broadcast,以及Thread的方式来实现。MyBatteryService后台获取Battery属性值,然后,在Activity中进行相关数据的显示。
获取电池电量的多少,或者电池其它一些信息。
Android-有没有什么方法能够快速、实时的获取android手机的电量值? - 德问编程社交问答
获取android手机的电量WiFi运营商的信息,目前只有这些功能,其他的暂时没想到
这个应用很简单就是获取Android中手机中应用用电排行的,很方便实用的
利用广播获取手机 实时电量信息
简单的android取电量源码,直接打开工程,可自己在原有基础上添加修改。
App电量计算统计和硬件耗电量计算,代码里面详细介绍
实验十一 通过系统广播获取手机电量的变化
有自己简单封装的一个接口。文件中也有官方的例子,可以自己下来改改。 相关博客为:http://blog.csdn.net/fansongy/article/details/8927734
这个例子主要是获取Android系统手机的电量信息,使用了intent.getExtras()方法来获取实现,关于此方法的使用,请参考以下的代码: public void onReceive(Context context, Intent intent) {//重写onReceiver方法 ...
本篇文章对用Android获取系统cpu信息,内存,版本,电量等信息的方法进行了详细的分析介绍。需要的朋友参考下
计算目前的手机电量还能撑多久 主要取决于 xml 解析和 PowerProfile里面的定义 来获取 值 最后靠计算来 得到 还能打电话多久 看电子书多久等等 代码没写完 后面会续上 但是这已经可以看到效果了
接收系统广播实现查看电池电量,这里用到了 Intent.ACTION_BATTERY_CHANGED 事件