如何启用手机的蓝牙编程,未经用户许可? [英] How to enable phone bluetooth programmatically, without the users permission?

查看:142
本文介绍了如何启用手机的蓝牙编程,未经用户许可?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android应用程序,允许用户控制自己的车辆的中央锁定系统,从而消除了小型遥控钥匙标签的需要。
但据我迄今所做,每次用户打开应用程序,他的手机蓝牙必须手动开启,如它要求用户的权限。

I'm developing an android app that allows the user to control the central locking system of his vehicle, thus eliminating the need of the small remote key tag. But According to what I have done so far, everytime the user opens the app, his phone bluetooth has to be turned on manually, as in it asks for the users permission.

因此​​,我需要知道的是,有没有办法以编程方式打开手机的蓝牙适配器,让每次应用程序启动,手机蓝牙将自动启用。

So what I need to know is, is there a way to turn on the phone bluetooth adapter programmatically, so that everytime the app is launched, the phone bluetooth will be enabled automatically.

我希望我的问题是清楚的。我是新来了Android编程领域。

I hope my question is clear. I'm new to the android programming field.

P.S - 如果你想知道如何在手机和车辆之间的通信完成后,有一些线路和车辆连接到单片机的蓝牙模块

P.s - If you're wondering how the communication between the phone and the vehicle is done, there are some circuits and a bluetooth module connected to a microcontroller in the vehicle.

推荐答案

是的,这是可能的。

btAdapter = BluetoothAdapter.getDefaultAdapter();
        if (btAdapter == null) 
        {
            // Device does not support Bluetooth
            Toast.makeText(getApplicationContext(), "Device does not support bluetooth", Toast.LENGTH_LONG).show();
        }
        else
        {
            if (!btAdapter.isEnabled()) 
            {
            btAdapter.enable();
            Toast.makeText(getApplicationContext(), "Bluetooth switched ON", Toast.LENGTH_LONG).show();


            }

这篇关于如何启用手机的蓝牙编程,未经用户许可?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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