#33 only start discovery activity when bt is enabled

This commit is contained in:
cpfeiffer 2015-05-07 22:15:53 +02:00
parent cf360455a0
commit 1604ae2c22
2 changed files with 7 additions and 1 deletions

View File

@ -111,7 +111,7 @@ public class ControlCenter extends Activity {
startService(startIntent);
if (deviceList.isEmpty()) {
if (GB.isBluetoothEnabled() && deviceList.isEmpty()) {
// start discovery when no devices are present
startActivity(new Intent(this, DiscoveryActivity.class));
} else {

View File

@ -3,6 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -73,6 +74,11 @@ public class GB {
}
}
static boolean isBluetoothEnabled() {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
return adapter != null && adapter.isEnabled();
}
public static String hexdump(byte[] buffer, int offset, int length) {
final char[] hexArray = "0123456789ABCDEF".toCharArray();
char[] hexChars = new char[length * 2];