WEB开发网
开发学院手机开发Android 开发 Android事件处理分 阅读

Android事件处理分

 2010-09-10 00:47:00 来源:WEB开发网   
核心提示:android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);try {RawInputEvent ev = new RawInputEvent();while (true) {InputDevice di

android.os.Process.setThreadPriority(

android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);

try {

RawInputEvent ev = new RawInputEvent();

while (true) {

InputDevice di;

// block, doesn't release the monitor

readEvent(ev);

boolean send = false;

boolean configChanged = false;

if (false) {

Log.i(TAG, "Input event: dev=0x"

+ Integer.toHexString(ev.deviceId)

+ " type=0x" + Integer.toHexString(ev.type)

+ " scancode=" + ev.scancode

+ " keycode=" + ev.keycode

+ " value=" + ev.value);

}

if (ev.type == RawInputEvent.EV_DEVICE_ADDED) {

synchronized (mFirst) {

di = newInputDevice(ev.deviceId);

mDevices.put(ev.deviceId, di);

configChanged = true;

}

}

......

}

}

}

};

Thread mThread = new Thread("InputDeviceReader") {

public void run() {

android.os.Process.setThreadPriority(

android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);

try {

RawInputEvent ev = new RawInputEvent();

while (true) {

InputDevice di;

// block, doesn't release the monitor

readEvent(ev);

boolean send = false;

boolean configChanged = false;

if (false) {

Log.i(TAG, "Input event: dev=0x"

+ Integer.toHexString(ev.deviceId)

+ " type=0x" + Integer.toHexString(ev.type)

+ " scancode=" + ev.scancode

+ " keycode=" + ev.keycode

+ " value=" + ev.value);

}

if (ev.type == RawInputEvent.EV_DEVICE_ADDED) {

synchronized (mFirst) {

di = newInputDevice(ev.deviceId);

mDevices.put(ev.deviceId, di);

configChanged = true;

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android 事件 处理

编辑录入:coldstar [复制链接] [打 印]
赞助商链接