android 请求蓝牙,android接收到蓝牙配对请求时如何点亮屏幕具体实现

Android系统都是支持蓝牙通信栈,并且允许设备和其他设备无线传输数据,而我们开发的时候一般都是通过androidapi调用蓝牙功能,下面爱站技术频道小编给大家详细介绍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

看了上面的介绍,相信大家对android接收到蓝牙配对请求时如何点亮屏幕具体实现已经很清楚了,赶紧把爱站技术频道分享给身边的朋友一起学习吧!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值