When I\'m trying to get default bluetooth adapter while i\'m NOT in Activity, but in TimerTask (created inside Service) by using:
B
Beware of a gotcha that exists in 2.3.x, but which has been fixed in 4.x: if you call BluetoothAdapter.getDefaultAdapter() on any thread other than the main application thread, that thread must call Looper.prepare() and also subsequently Looper.loop().
Failing to do so will cause at least one problem that I ran into: accept() will succeed the first time you try to connect, but then not succeed on successive attempts, even after using close() on the ServerSocket.
This happens because in the older implementation of BluetoothAdapter, the cleanup of the SDP entry occurs by way of a message posted to a handler created on the thread where getDefaultAdapter() is called.