We can now list supported bluetooth services

This commit is contained in:
Alexandros Schillings
2015-07-13 17:13:06 +01:00
parent eae8e9c776
commit 4e173659e9
5 changed files with 83 additions and 0 deletions
@@ -19,6 +19,7 @@ import java.util.Locale;
import butterknife.Bind;
import butterknife.ButterKnife;
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
import uk.co.alt236.bluetoothlelib.device.BluetoothService;
import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecord;
import uk.co.alt236.bluetoothlelib.device.mfdata.IBeaconManufacturerData;
import uk.co.alt236.bluetoothlelib.resolvers.CompanyIdentifierResolver;
@@ -56,6 +57,7 @@ public class DeviceDetailsActivity extends AppCompatActivity {
final TextView tvAddress = (TextView) lt.findViewById(R.id.deviceAddress);
final TextView tvClass = (TextView) lt.findViewById(R.id.deviceClass);
final TextView tvMajorClass = (TextView) lt.findViewById(R.id.deviceMajorClass);
final TextView tvServices = (TextView) lt.findViewById(R.id.deviceServiceList);
final TextView tvBondingState = (TextView) lt.findViewById(R.id.deviceBondingState);
tvName.setText(device.getName());
@@ -64,6 +66,24 @@ public class DeviceDetailsActivity extends AppCompatActivity {
tvMajorClass.setText(device.getBluetoothDeviceMajorClassName());
tvBondingState.setText(device.getBluetoothDeviceBondState());
final String supportedServices;
if(device.getBluetoothDeviceKnownSupportedServices().isEmpty()){
supportedServices = getString(R.string.no_known_services);
} else {
final StringBuilder sb = new StringBuilder();
for(final BluetoothService service : device.getBluetoothDeviceKnownSupportedServices()){
if(sb.length() > 0){
sb.append(", ");
}
sb.append(service);
}
supportedServices = sb.toString();
}
tvServices.setText(supportedServices);
adapter.addView(lt);
}
@@ -52,6 +52,16 @@
android:id="@+id/deviceMajorClass"
style="@style/GridLayoutDataTextView"/>
<TextView
style="@style/GridLayoutTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_device_services"/>
<TextView
android:id="@+id/deviceServiceList"
style="@style/GridLayoutDataTextView"/>
<TextView
style="@style/GridLayoutTitleTextView"
android:layout_width="wrap_content"
@@ -15,6 +15,7 @@
<string name="unknown_characteristic">Unknown characteristic</string>
<string name="unknown_device">Unknown device</string>
<string name="unknown_service">Unknown service</string>
<string name="no_known_services">No known services</string>
<!-- Formatters -->
<string name="formatter_meters">%sm</string>
@@ -54,6 +55,7 @@
<string name="label_device_address">Device address:</string>
<string name="label_device_class">Device Class:</string>
<string name="label_device_major_class">Major Class:</string>
<string name="label_device_services">Services:</string>
<string name="label_device_name">Device Name:</string>
<string name="label_distance">Distance:</string>
<string name="label_first_rssi">First RSSI:</string>