Nokia3100的手电筒
来源:互联网 发布:js md5加密例子 编辑:程序博客网 时间:2024/04/29 22:58
Nokia3100居然没有提供手电筒的功能,黑暗中实在是不方便。
前一段刚看了J2ME的开发,Nokia UI API v1.0里提供了setLights(int num, int level) 方法,于是就写了个手电筒的程序放在自己手机上用,呵呵。。。代码如下:
另外,com.nokia.mid.ui.DeviceControl还提供了闪光和振动的api:
Method Summary
Temporarily flashes the lights for a specific length of time given as milliseconds in duration parameter.
Activates and deactivates the lights on the device.
Activates vibration for a given length of time and frequency.
Stops any vibration.
前一段刚看了J2ME的开发,Nokia UI API v1.0里提供了setLights(int num, int level) 方法,于是就写了个手电筒的程序放在自己手机上用,呵呵。。。代码如下:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import com.nokia.mid.ui.DeviceControl;
/**
*
* @author Autumn
*/
public class Light extends MIDlet implements CommandListener {
private Display display = null;
private Command onCommand = new Command("开", Command.OK, 1);
private Command offCommand = new Command("关", Command.OK, 1);
private Command exitCommand = new Command("退出", Command.EXIT, 1);
private Form form1;
private StringItem si;
/** Creates a new instance of Light */
public Light() {
form1 = new Form("手电筒");
si = new StringItem("手电筒状态:","开");
}
protected void startApp() throws MIDletStateChangeException {
if(display == null)
display = Display.getDisplay(this);
form1.append(si);
form1.addCommand(exitCommand);
lights(100, offCommand,"开");
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void commandAction(Command cmd, Displayable displayable) {
//退出
if (cmd == exitCommand) {
// stop the MIDlet
destroyApp(true);
}
//打开
if(cmd == onCommand){
form1.removeCommand(onCommand);
lights(100, offCommand,"开");
}
//关闭
if(cmd == offCommand){
form1.removeCommand(offCommand);
lights(0, onCommand,"关");
}
}
public void lights(int level, Command cmd, String s) {
si.setText(s);
DeviceControl.setLights(0, level);
form1.addCommand(cmd);
form1.setCommandListener(this);
display.setCurrent(form1);
}
}
import javax.microedition.midlet.*;
import com.nokia.mid.ui.DeviceControl;
/**
*
* @author Autumn
*/
public class Light extends MIDlet implements CommandListener {
private Display display = null;
private Command onCommand = new Command("开", Command.OK, 1);
private Command offCommand = new Command("关", Command.OK, 1);
private Command exitCommand = new Command("退出", Command.EXIT, 1);
private Form form1;
private StringItem si;
/** Creates a new instance of Light */
public Light() {
form1 = new Form("手电筒");
si = new StringItem("手电筒状态:","开");
}
protected void startApp() throws MIDletStateChangeException {
if(display == null)
display = Display.getDisplay(this);
form1.append(si);
form1.addCommand(exitCommand);
lights(100, offCommand,"开");
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void commandAction(Command cmd, Displayable displayable) {
//退出
if (cmd == exitCommand) {
// stop the MIDlet
destroyApp(true);
}
//打开
if(cmd == onCommand){
form1.removeCommand(onCommand);
lights(100, offCommand,"开");
}
//关闭
if(cmd == offCommand){
form1.removeCommand(offCommand);
lights(0, onCommand,"关");
}
}
public void lights(int level, Command cmd, String s) {
si.setText(s);
DeviceControl.setLights(0, level);
form1.addCommand(cmd);
form1.setCommandListener(this);
display.setCurrent(form1);
}
}
另外,com.nokia.mid.ui.DeviceControl还提供了闪光和振动的api:
Method Summary
static void
flashLights(long duration)
Temporarily flashes the lights for a specific length of time given as milliseconds in duration parameter.
static void
setLights(int num, int level)
Activates and deactivates the lights on the device.
static void
startVibra(int freq, long duration)
Activates vibration for a given length of time and frequency.
static void
stopVibra()
Stops any vibration.
- Nokia3100的手电筒
- android 手电筒的实现
- 手电筒的制作
- 打开Camera的手电筒
- 手电筒
- MB526上的手电筒软件
- android 简单的手电筒制作
- 闪光灯的使用---制作手电筒
- Android 手电筒的开启方法
- NOKIA3100又可以开机了
- 实现手电筒查找的功能(一)
- Android 七彩手电筒的实现与应用
- 打开我的电脑出现手电筒
- 开启android设备的闪光灯作为手电筒
- android 开启闪关灯手电筒的实现
- 基于Android平台开发的手电筒Light
- 系统开关,wifi、手电筒等的开关
- android 相机与手电筒的互斥
- 在PB中利用DDE
- 使用画刷在背景中平铺位图
- ASP.NET AJAX 1.0 RC版发布了
- iostate 就是流的状态
- 三则微软产品消息:Robotics Studio, VS 2005 SP1,和ASP.NET AJAX RC
- Nokia3100的手电筒
- WPF简介
- SQL Server安装文件挂起错误解决办法
- C++面试题3
- html中utf-8的问题
- c# 语句实现屏幕抓图
- 外汇投资入门
- 《国富论》笔记(序)
- CVS客户端大全