是否有可能时,蓝牙连接到我的设备得到了应用通知? [英] Is it possible to get notified in the application when bluetooth connects to my device?

查看:123
本文介绍了是否有可能时,蓝牙连接到我的设备得到了应用通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个Android应用程序,与我的BT设备交互并唤醒他。

I want to build a Android application that interacts with my BT device and wakes him.


  • 的装置,和在电话配对

  • 设备不断地扫描了特定的手机,每个手机在范围内时请求连接。

我想知道是否有可能对我的申请得到通知每一个设备要求连接时间。考虑到该应用程序是不活跃。

I want to know is it possible for my application to get notified every time the device asks for connection. Take into consideration that the application is not active.

例如,当我进入它会自动连接到我的车BT的车,当我得到通话,通话应用程序被激活? (但也许这件事情,Android的内部呢...)

For example, when i get into the car it connects automatically to my car BT and when i get call, the call application is activated? (but maybe that's something that Android internally does...)

任何想法?

推荐答案

是当一个新的设备使用广播的接收器连接,你可以得到通知。
请参阅下面的code。

Yes you can get notified when a new device is connected using Broadcast receiver. Please refer to the code below.

BroadcastReceiver btReceive=new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
           //the device is found
         }
    }
};

这篇关于是否有可能时,蓝牙连接到我的设备得到了应用通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆