android接收到藍(lán)牙配對(duì)請(qǐng)求時(shí)如何點(diǎn)亮屏幕具體實(shí)現(xiàn)
更新時(shí)間:2013年06月17日 15:31:54 作者:
android 在接收到藍(lán)牙配對(duì)請(qǐng)求時(shí)如何自動(dòng)點(diǎn)亮屏幕配對(duì)過程中很實(shí)用,具體的實(shí)現(xiàn)思路及代碼如下,感興趣的朋友可以參考下哈
file: BluetoothEventLoop.java
GB/GB2/GB3:
1. import android.os.PowerManager;
2. 變量申明:private PowerManager.WakeLock mWakeLock;
3. BluetoothEventLoop(){} 構(gòu)造函數(shù)里面添加定義:
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步;
對(duì)4、5、6、7、8中修改的function中:將原生的mWakeLock.acquire(); 改為mWakeLock.acquire(5000), 刪掉對(duì)應(yīng)function中的mWakeLock.release();
修改完后,模塊會(huì)被編譯進(jìn)framework.jar
GB/GB2/GB3:
1. import android.os.PowerManager;
2. 變量申明:private PowerManager.WakeLock mWakeLock;
3. BluetoothEventLoop(){} 構(gòu)造函數(shù)里面添加定義:
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步;
對(duì)4、5、6、7、8中修改的function中:將原生的mWakeLock.acquire(); 改為mWakeLock.acquire(5000), 刪掉對(duì)應(yīng)function中的mWakeLock.release();
修改完后,模塊會(huì)被編譯進(jìn)framework.jar
相關(guān)文章
解決android studio 3.0 加載項(xiàng)目過慢問題--maven倉(cāng)庫(kù)選擇
這篇文章主要介紹了android studio 3.0 加載項(xiàng)目過慢問題解決方案---maven倉(cāng)庫(kù)選擇,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-11-11
TextView顯示系統(tǒng)時(shí)間(時(shí)鐘功能帶秒針變化
用System.currentTimeMillis()可以獲取系統(tǒng)當(dāng)前的時(shí)間,我們可以開啟一個(gè)線程,然后通過handler發(fā)消息,來(lái)實(shí)時(shí)的更新TextView上顯示的系統(tǒng)時(shí)間,可以做一個(gè)時(shí)鐘的功能2013-11-11
AndroidStudio圖片壓縮工具ImgCompressPlugin使用實(shí)例
這篇文章主要為大家介紹了AndroidStudio圖片壓縮工具ImgCompressPlugin使用實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08
Android SD卡上文件操作及記錄日志操作實(shí)例分析
這篇文章主要介紹了Android SD卡上文件操作及記錄日志操作的方法,涉及Android針對(duì)SD卡與文件操作的相關(guān)技巧,需要的朋友可以參考下2016-01-01
Android畫圖之抗鋸齒paint和Canvas兩種方式實(shí)例
本篇文章主要介紹了Android畫圖之抗鋸齒paint和Canvas兩種方式實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04
android 實(shí)現(xiàn)類似微信緩存和即時(shí)更新好友頭像示例
本篇文章主要介紹了android 實(shí)現(xiàn)類似微信緩存和即時(shí)更新好友頭像示例,具有一定的參考價(jià)值,有興趣的可以了解一下。2017-01-01
解決Android使用Handler造成內(nèi)存泄露問題
內(nèi)存泄露的危害就是會(huì)使虛擬機(jī)占用內(nèi)存過高,導(dǎo)致OOM(內(nèi)存溢出),程序出錯(cuò)。接下來(lái)通過本文給大家分享Android使用Handler造成內(nèi)存泄露問題及解決方法,一起看看吧2017-08-08

