MB526上的手电筒软件
来源:互联网 发布:linux没有 telnet命令 编辑:程序博客网 时间:2024/04/29 07:57
本文参考至:http://download.csdn.net/detail/chenxupro/3884639,一个下载链接
网上看过N多个文章,但均不适用于MB526,上面的资源刚好符合,系统是2.3.6的,不保障适用于所有系统,其他手机很多都是利用相机来实现手电筒功能的,但MB526就是不可以,只能用这种方式了。
class DroidLED {private Object svc = null;private Method getFlashlightEnabled = null;private Method setFlashlightEnabled = null;@SuppressWarnings("unchecked")public DroidLED() throws Exception {try {// call ServiceManager.getService("hardware") to get an IBinder for the service.// this appears to be totally undocumented and not exposed in the SDK whatsoever.Class sm = Class.forName("android.os.ServiceManager");Object hwBinder = sm.getMethod("getService", String.class).invoke(null, "hardware");// get the hardware service stub. this seems to just get us one step closer to the proxyClass hwsstub = Class.forName("android.os.IHardwareService$Stub");Method asInterface = hwsstub.getMethod("asInterface", android.os.IBinder.class);svc = asInterface.invoke(null, (IBinder) hwBinder);// grab the class (android.os.IHardwareService$Stub$Proxy) so we can reflect on its methodsClass proxy = svc.getClass();// save methodsgetFlashlightEnabled = proxy.getMethod("getFlashlightEnabled");setFlashlightEnabled = proxy.getMethod("setFlashlightEnabled", boolean.class);}catch(Exception e) {throw new Exception("LED could not be initialized");}}public boolean isEnabled() {try {return getFlashlightEnabled.invoke(svc).equals(true);}catch(Exception e) {return false;}}public void enable(boolean tf) {try {setFlashlightEnabled.invoke(svc, tf);}catch(Exception e) {}}}通过该类实现对闪光灯的控制,在activity中定义DroidLED对象,利用enable(boolen tf)接口来实现对闪光灯的控制,传递true,打开闪关灯;传递false则关闭闪光灯。此外,加上闪光灯权限即可
<uses-permission android:name="android.permission.FLASHLIGHT" />
ps:http://download.csdn.net/detail/key123zhangxing/4625001,糅合别人的代码和图片资源,欢迎下载。
- MB526上的手电筒软件
- MIDP2.0手机上的手电筒程序(附代码)
- MIDP2.0手机上的手电筒程序(附代码)
- Nokia3100的手电筒
- android 手电筒的实现
- 手电筒的制作
- 打开Camera的手电筒
- 手电筒
- Nokia系列手机上的一个手电筒J2ME程序(附源代码)
- [wp7软件]wp7~~手电筒应用~~集合贴~~
- 【Android】超级手电筒项目总结(上)
- android 简单的手电筒制作
- 闪光灯的使用---制作手电筒
- Android 手电筒的开启方法
- 摩托罗拉MB526— Android 4.4.4 — 包含的共享库文件 —lib*.so
- 实现手电筒查找的功能(一)
- Android 七彩手电筒的实现与应用
- 打开我的电脑出现手电筒
- encodeURI和encodeURIComponent(处理JS乱码)
- Android中BaseAdapter基础类 之一
- memset和fill_n的比较
- MonkeyRunner_wrapEasyMonkey howto入门教程1.0
- oracle 表中的一个字段的值添加一个字符
- MB526上的手电筒软件
- profiling调试好帮手
- .NET XML
- 在Outlook 2007中如何设置新邮件的默认字体?
- Android中BaseAdapter基础类
- 关于property.
- Java SE 学习笔记 第三记
- android Gallery(Gallery图片下面有文字)
- unit UnitMyClass;