【问题标题】:bluetooth settings+android蓝牙设置+安卓
【发布时间】:2011-11-24 12:33:47
【问题描述】:

在我的应用程序中,我需要检查设备是否可发现以及蓝牙是打开还是关闭我应用了这样的代码

bluetoothenable=Settings.Secure.getInt(myContext.getContentResolver(),
android.provider.Settings.Secure.BLUETOOTH_ON);

当我在设置中检查蓝牙但可发现时,它提供了真正的价值 我添加此代码

bluetooth=Settings.System.getInt(myContext.getContentResolver(),
android.provider.Settings.System.BLUETOOTH_DISCOVERABILITY);

它给我设置未找到异常不是我检查的任何值 android.provider.Settings.System 如果我们无法读取设置值,则会出现此错误 android.provider.Settings.System?

【问题讨论】:

    标签: android bluetooth settings


    【解决方案1】:

    您可以设置BluetoothAdapter。使用此适配器,您可以获得 isEnabled() 和 getScanMode()

    【讨论】:

    • 这真的是获取当前蓝牙设置信息的唯一选择吗?我在几款三星和 HTC 设备上尝试过Settings.System.getInt( getContentResolver(), Settings.System.BLUETOOTH_DISCOVERABILITY )Settings.System.getInt( getContentResolver(), Settings.System.BLUETOOTH_DISCOVERABILITY_TIMEOUT ),它们都抛出了 android.provider.Settings.SettingNotFoundException。如果它根本不起作用,为什么他们实际上提供该设置提供程序? ://
    • 它可能可以按照你的方式完成......但我从来没有这样做过。我只有在我已经设置好蓝牙适配器时才需要,所以......我无法给出更好的答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多