80,472
社区成员




public class ShowDialg
{
public static Dialog CreateShowListViewDialog(final Context context, String title, final BluetoothGattServiceAdapter bluetoothGattServiceAdapter)
{
LayoutInflater layoutInflater = LayoutInflater.from(context);
View contentView = layoutInflater.inflate(R.layout.activity_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(contentView);
builder.setTitle(title);
final ExpandableListView listView = (ExpandableListView) contentView.findViewById(R.id.lv_dialog);
try
{
listView.setAdapter(bluetoothGattServiceAdapter);
}
catch (Exception E)
{
E.printStackTrace();
}
return builder.create();
}
}
private BroadcastReceiver mBluetoothLEBroadcaseReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
switch (action)
{
//查找设备成功,填充LISTVIEW
case BluetoothLEFinalStaticValue.BLUETOOTH_ACTION_START_DISCOVERY_DEVICE:
Log.d(TAG, "连接设备成功...");
addList(mBluetoothLeService.getBluetoothLESupportService());
break;
}
}
};
public void addList(List<BluetoothGattService> bluetoothGattServiceList)
{
String uuid;
String rwString = new String();
String unknownServiceString = "Unknown service";
String unknownCharaString = "Unknown characteristic";
BluetoothGattService bluetoothGattService;
BluetoothLEGattServiceJaveBean bluetoothLEGattServiceJaveBean;
BluetoothLEGattCharacterJaveBean bluetoothLEGattCharacterJaveBean;
BluetoothGattCharacteristic bluetoothGattCharacteristic;
List<BluetoothGattCharacteristic> bluetoothGattCharacteristicList;
for(int ik=0; ik<bluetoothGattServiceList.size(); ik++)
{
bluetoothLEGattServiceJaveBean = new BluetoothLEGattServiceJaveBean();
bluetoothGattService = bluetoothGattServiceList.get(ik);
bluetoothGattCharacteristicList = bluetoothGattService.getCharacteristics();
uuid = bluetoothGattService.getUuid().toString();
bluetoothLEGattServiceJaveBean.setmSeriveUUID(uuid);
bluetoothLEGattServiceJaveBean.setmSeriveuuidStringName(SampleGattAttributes.lookup(uuid, unknownServiceString));
//在一个Service里面包含多个特征值
for(int jk=0; jk<bluetoothGattCharacteristicList.size(); jk++)
{
bluetoothLEGattCharacterJaveBean = new BluetoothLEGattCharacterJaveBean();
bluetoothGattCharacteristic = bluetoothGattCharacteristicList.get(jk);
int charaProp = bluetoothGattCharacteristic.getProperties();
if ((charaProp & BluetoothGattCharacteristic.PROPERTY_READ) > 0)
{
rwString = "可读 ";
}
if ((charaProp & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0)
{
rwString = rwString + "可写 ";
}
if ((charaProp & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0)
{
rwString = rwString + "可通知";
}
if(rwString.equals(""))
{
rwString = "UnKonw properties = " + charaProp;
}
uuid = bluetoothGattCharacteristic.getUuid().toString();
bluetoothLEGattCharacterJaveBean.setmCharacterUUID(uuid);
bluetoothLEGattCharacterJaveBean.setmCaracteruuidStringName(SampleGattAttributes.lookup(uuid, unknownCharaString));
bluetoothLEGattCharacterJaveBean.setmRWString(rwString);
bluetoothLEGattServiceJaveBean.getBluetoothLEGattCharacterJaveBeanList().add(bluetoothLEGattCharacterJaveBean);
Log.d("特征值 uuid = ", uuid);
Log.d("character = " + charaProp, "rwString = " + rwString);
rwString = "";
}
mListBluetoothLEGattServiceJaveBean.add(bluetoothLEGattServiceJaveBean);
mBluetoothGattServiceAdapter.notifyDataSetChanged();
Message msg = Message.obtain();
msg.what = BluetoothLEFinalStaticValue.SHOW_DIALOG;
mHandler.sendMessage(msg);
}
}
public Handler mHandler = new Handler(){
@Override
public void handleMessage(Message msg)
{
switch (msg.what)
{
case BluetoothLEFinalStaticValue.SHOW_DIALOG:
if(!mIsCreted)
{
Log.d(TAG, "第一次显示.......");
mIsCreted = true;
mDialog = ShowDialg.CreateShowListViewDialog(DeviceControlActivity.this, mTvDeviceName.getText().toString(), mBluetoothGattServiceAdapter);
}
mDialog.show();
break;
}
}
};
08-16 20:01:17.828 19999-19999/? I/art: Late-enabling -Xcheck:jni
08-16 20:01:17.888 19999-19999/com.ble W/System: ClassLoader referenced unknown path: /data/app/com.ble-2/lib/arm
08-16 20:01:17.992 19999-20031/com.ble D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
08-16 20:01:17.998 19999-19999/com.ble D/ActivityThreadInjector: clearCachedDrawables.
08-16 20:01:18.046 19999-20031/com.ble I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013_msm8974_refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013__release_AU (I48a9d37399)
OpenGL ES Shader Compiler Version: E031.29.00.00
[/quote]没接触过这类异常。你先看看楼下的解决方案有没有效果。[/quote]
如果,我不往mListBluetoothLEGattServiceJaveBean这个List 添加数据,及Adapter 为空的时候,对话框是可以显示出来的。
但是,只要Adapter 里面有数据,就会出现上面的问题,还是找不到原因,快无语了。
08-16 20:01:17.828 19999-19999/? I/art: Late-enabling -Xcheck:jni
08-16 20:01:17.888 19999-19999/com.ble W/System: ClassLoader referenced unknown path: /data/app/com.ble-2/lib/arm
08-16 20:01:17.992 19999-20031/com.ble D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
08-16 20:01:17.998 19999-19999/com.ble D/ActivityThreadInjector: clearCachedDrawables.
08-16 20:01:18.046 19999-20031/com.ble I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013_msm8974_refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013__release_AU (I48a9d37399)
OpenGL ES Shader Compiler Version: E031.29.00.00
[/quote]没接触过这类异常。你先看看楼下的解决方案有没有效果。[/quote]
如果,我不往mListBluetoothLEGattServiceJaveBean这个List 添加数据,及Adapter 为空的时候,对话框是可以显示出来的。
但是,只要Adapter 里面有数据,就会出现上面的问题,还是找不到原因,快无语了。
08-16 20:01:17.828 19999-19999/? I/art: Late-enabling -Xcheck:jni
08-16 20:01:17.888 19999-19999/com.ble W/System: ClassLoader referenced unknown path: /data/app/com.ble-2/lib/arm
08-16 20:01:17.992 19999-20031/com.ble D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
08-16 20:01:17.998 19999-19999/com.ble D/ActivityThreadInjector: clearCachedDrawables.
08-16 20:01:18.046 19999-20031/com.ble I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013_msm8974_refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013__release_AU (I48a9d37399)
OpenGL ES Shader Compiler Version: E031.29.00.00
[/quote]没接触过这类异常。你先看看楼下的解决方案有没有效果。
08-16 20:01:17.828 19999-19999/? I/art: Late-enabling -Xcheck:jni
08-16 20:01:17.888 19999-19999/com.ble W/System: ClassLoader referenced unknown path: /data/app/com.ble-2/lib/arm
08-16 20:01:17.992 19999-20031/com.ble D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
08-16 20:01:17.998 19999-19999/com.ble D/ActivityThreadInjector: clearCachedDrawables.
08-16 20:01:18.046 19999-20031/com.ble I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013_msm8974_refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013__release_AU (I48a9d37399)
OpenGL ES Shader Compiler Version: E031.29.00.00