Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發實例 >> android接收到藍牙配對請求時如何點亮屏幕具體實現

android接收到藍牙配對請求時如何點亮屏幕具體實現

編輯:Android開發實例

file: BluetoothEventLoop.java
GB/GB2/GB3:
1. import android.os.PowerManager;
2. 變量申明:private PowerManager.WakeLock mWakeLock;
3. BluetoothEventLoop(){} 構造函數裡面添加定義:
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.ON_AFTER_RELEASE, TAG);
mWakeLock.setReferenceCounted(false);
4. onRequestPairingConsent(){
...
mWakeLock.acquire(5000); // xintong , 亮屏5s
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
...
}
5. onRequestPasskeyConfirmation(){
...
mWakeLock.acquire(5000); // xintong , 亮屏5s
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
...
}
6. onRequestPasskey(){
...
mWakeLock.acquire(5000); // xintong , 亮屏5s
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
...
}
7. onRequestPinCode(){
...
mWakeLock.acquire(5000); // xintong 亮屏5s
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
...
}
8. onDisplayPasskey(){
...
mWakeLock.acquire(5000); // xintong , 亮屏5s
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
...
}
ICS/ICS2/JB/JB2/JB3:
省略掉GB中修改的第1、2、3步;
對4、5、6、7、8中修改的function中:將原生的mWakeLock.acquire(); 改為mWakeLock.acquire(5000), 刪掉對應function中的mWakeLock.release();
修改完後,模塊會被編譯進framework.jar
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved