任何方式在iOS7 +上以编程方式打开蓝牙(Any way to turn on bluetooth programmatically on iOS7+)
我听说iOS7引入了CBCentralManager的这个功能,但是找不到方法。 有可能吗? 还有另一种方式使用GKPeerPickerController进行宽度调整吗?
I hear that iOS7 introduced this functionality with CBCentralManager but can't find how. Is possible? There is another way widthout use GKPeerPickerController?
更新时间:2023-03-21 12:03
最满意答案
不,如果用户关闭了蓝牙,您只能显示一条提示或消息,要求他们打开它。
- (void)centralManagerDidUpdateState:(CBCentralManager *)central { if (central.state == CBCentralManagerStatePoweredOff) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Error" message: @"Please turn on Bluetooth in Settings" delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } }
No, if the user has turned off Bluetooth all you can do is display an alert or message asking them to turn it on.
- (void)centralManagerDidUpdateState:(CBCentralManager *)central { if (central.state == CBCentralManagerStatePoweredOff) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Error" message: @"Please turn on Bluetooth in Settings" delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } }
相关问答
更多-
如果Apple批准修改用户天线设置的应用程序,那将会有些令人惊讶。 这听起来像他们通常不喜欢的东西,不管你怎么做。 但是,有时候我会感到惊讶。 你绝对可以通过Applescript完成它: tell application "System Preferences" set current pane to pane "com.apple.preferences.Bluetooth" tell application "System Events" tell process "S ...
-
我不相信以编程方式打开VoiceOver是可能的。 I don't believe it's possible to turn VoiceOver on programatically.
-
有没有办法以编程方式打开/关闭iPhone中的蓝牙?(Is there any way to switch on/off bluetooth in iPhone programmatically?)[2022-06-15]
请注意,您将无法在App Store上发布应用程序,因为这样做必须使用私有API。 如果你仍然想这样做,你应该阅读这个链接: 有没有办法在iOS中以编程方式打开和关闭蓝牙和/或WiFi? 请注意添加GameKit框架以使其可以正常工作,而不是像添加.h文件等那样使用其他所有东西,除非gameKit不能解决所有问题。 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)la ... -
我会给你一些提示: 1.)启用蓝牙: mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter != null) { if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent( BluetoothA ...
-
如何以编程方式打开和关闭OSX上的蓝牙,WiFi和声音(How to programmatically turn on and off bluetooth, wifi and sound on OSX)[2022-04-12]
只需执行正确的命令:-)你甚至可以使用AppleScript。 Wifi: ifconfig en1 off或networksetup -setairportpower off 蓝牙:您可能需要http://www.frederikseiffert.de/blueutil/ 亮度:我为你找到了这个c工具: http : //mattdanger.net/2008/12/adjust-mac-os-x-display-brightness-from-the-terminal/ 没有exec()调用可能都是可能 ... -
这是一个私有API。 将以下内容添加到桥接标头中: void IOBluetoothPreferenceSetControllerPowerState(int); 并将其调用1启用或0禁用: func setBluetooth(on: Bool) { IOBluetoothPreferenceSetControllerPowerState(on ? 1 : 0) } setBluetooth(on: true) 不要忘记在Swift文件中import IOBluetooth 。 要获取当前状态 ...
-
不,如果用户关闭了蓝牙,您只能显示一条提示或消息,要求他们打开它。 - (void)centralManagerDidUpdateState:(CBCentralManager *)central { if (central.state == CBCentralManagerStatePoweredOff) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Error" message: @"Please tu ...
-
以编程方式连接到Windows Mobile上的蓝牙耳机(Programmatically connect to bluetooth headsets on Windows Mobile)[2022-10-11]
我将开始在MSDN Windows Mobile 5.0文档中查找Blue Tooth APIS 。 将音频设备更改为蓝牙设备可能是一个难点。 根据您尝试切换的应用程序,您可能希望查看基于Windows Mobile的设备API的Waveform Audio 。 从来没有做过上述任何一项,我不能说它是否足够但它应该让你开始。 I would start looking in MSDN Windows Mobile 5.0 documentation for the Blue Tooth APIS. The ... -
在iOS 7中无法获取蓝牙地址。 It is not possible to get the Bluetooth Address in iOS 7.
-
您可以使用OS X私有API IOBluetoothPreferenceSetDiscoverableState。 // Declaration of private API void IOBluetoothPreferenceSetDiscoverableState(int discoverable); int IOBluetoothPreferenceGetDiscoverableState(); // Usage // Turn on Discoverability IOBluetoothPrefe ...