43

プログラムでONかOFFかというiPhone/iPod Bluetoothのステータスを取得しようとしています。Apple API またはサードパーティ API を使用することは可能ですか。

4

7 に答える 7

2

iOS 5 以降で CoreBluetooth を使用する方法があります。使用できるクラスは CBCentralManager です。Bluetoothがオンになっているかどうかを確認できる「状態」プロパティがあります。(enum CBCentralManagerState には、チェックしたい値があります)。

于 2012-08-02T15:28:51.703 に答える
0

このソリューションは、アップルがコアBluetoothを導入する前に、少し古いです

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.


        Class BluetoothManager = objc_getClass( "BluetoothManager" ) ;
        id btCont = [BluetoothManager sharedInstance] ;
        [self performSelector:@selector(status:) withObject:btCont afterDelay:1.0f] ;

        return YES ;
    }


    - (void)status:(id)btCont
    {
        BOOL currentState = [btCont enabled] ;
        //check the value of currentState 

    }
于 2011-07-07T06:37:45.027 に答える