Android 自定义Dialog 显示不显示问题??

新手,请教。小弟使用自定义Dialog和ExpandableListView 显示数据,但是却导致整个Activity闪退。
我思路是,使用Service 监听蓝牙BLE的广播的数据,然后Service通过Brodcast 的形式,将数据发送到Activity中,
然后,Activity的BroadcasrReciver 通过Hanler 显示对话框。 结果,就闪退了。。。。。

显示如下错误:
08-15 21:37:27.427 16027-16027/? I/art: Late-enabling -Xcheck:jni
08-15 21:37:27.517 16027-16027/com.ble W/System: ClassLoader referenced unknown path: /data/app/com.ble-1/lib/arm
这个问题困扰好久了,请指教。

代码如下:自定义对话框类
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;
}
}
};
addList() 方法
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;
}
}
};
请问一个各位大神有没有遇过这种问题,小弟是新手,请指教,谢谢了。
...全文
相关推荐
Android自定义显示内容的Dialog
Android自定义显示内容的Dialog,有两种实现方式,一个继承Dialog,一个继承PopupWindow。
Android自定义Dialog弹窗提示
Android开发自定义的Dialog弹窗提示,ke自定义样式、标题、内容......
Android Dialog更改样式及显示位置
Android Dialog更改样式及显示位置 效果: http://blog.csdn.net/amazing_alex/article/details/23273387
Android自定义dialog,可动画显示
代码基于dialog写的,进场出场动画,基本需求设置
android自定义Dialog弹框和背景阴影显示效果
主要介绍了android自定义Dialog弹框和背景阴影显示效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下


