How are the BluetoothDevice and condition of the BT-adapter (incl. / off)?

Good day, Habr!

Faced with this problem:
there is such here a piece of code:
private HashSet discoveredDevices;<br> @Override<br> public void onActivityCreated(Bundle savedInstanceState) {<br> super.onActivityCreated(savedInstanceState);<br> //....<br> mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();<br> if (savedInstanceState == null) {<br> discoveredDevices = new HashSet();<br> } else {<br> discoveredDevices = (HashSet) savedInstanceState.<br> .getSerializable("devices");<br> for (BluetoothDevice device : discoveredDevices) {<br> adapter.add(device.getName() + "\n" + device.getAddress());<br> }<br> }<br> //....<br> }<br> <br / > And code persistence:<br> <code> @Override<br> public void onSaveInstanceState(Bundle outState) {<br> super.onSaveInstanceState(outState);<br> outState.putSerializable("devices", discoveredDevices);<br> }<br> </code><br> If you turn off BT and turn off the screen (i.e. to get into the onActivityCreated handler), then in this place:<br> <code>discoveredDevices = (HashSet) savedInstanceState.getSerializable("devices");<br> <br / > the program crashes. <br / > Can anyone explain why is this happening?</code>
October 8th 19 at 01:12
1 answer
October 8th 19 at 01:14
Well, where are the logs?
Log was problematic... to Clarify the issue. - Modesto.Conroy60 commented on October 8th 19 at 01:17

Find more questions by tags BluetoothAndroid