onCreate()時のBluetooth対応チェックについて。
マニフェストファイルでbluetooth le対応かどうか判定しているのに、
DeviceScanActivity.javaでもbluetooth le対応かどうか判定しています。
DeviceScanActivityの62行目および74行目がtrueになることはあるのでしょうか?
保険でしょうか?
あと、77行目のreturn;はいりますか?
AndroidManifest.xml
xml
1 <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> 2 <uses-permission android:name="android.permission.BLUETOOTH"/> 3 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
DeviceScanActivity.java
java
154 @Override 255 public void onCreate(Bundle savedInstanceState) { 356 super.onCreate(savedInstanceState); 457 getActionBar().setTitle(R.string.title_devices); 558 mHandler = new Handler(); 659 760 // Use this check to determine whether BLE is supported on the device. Then you can 861 // selectively disable BLE-related features. 962 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { 1063 Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); 1164 finish(); 1265 } 1366 1467 // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to 1568 // BluetoothAdapter through BluetoothManager. 1669 final BluetoothManager bluetoothManager = 1770 (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 1871 mBluetoothAdapter = bluetoothManager.getAdapter(); 1972 2073 // Checks if Bluetooth is supported on the device. 2174 if (mBluetoothAdapter == null) { 2275 Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); 2376 finish(); 2477 return; 2578 } 2679 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/10 22:59