Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("service", (Serializable) mChatService);
intent.putExtras(bundle);提示bundle.putSerializable这句出错,classCastException,mChatService是BluetoothChatService类型的,这个问题怎么解决?
Bundle bundle = new Bundle();
bundle.putSerializable("service", (Serializable) mChatService);
intent.putExtras(bundle);提示bundle.putSerializable这句出错,classCastException,mChatService是BluetoothChatService类型的,这个问题怎么解决?
是源码里的例子,源码实现的是蓝牙聊天,我已经把BluetoothChatService这个类implements Serializable了,还是同样的错误,我在BluetoothChat里加的代码:
case MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
// construct a string from the valid bytes in the buffer
String readMessage = new String(readBuf, 0, msg.arg1);
mConversationArrayAdapter.add(mConnectedDeviceName+": " + readMessage);
//如果双方都准备好,这开始对战
if(readMessage.equals("ready") && isReady == true){
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("service", (Serializable) mChatService);
intent.putExtras(bundle);
intent.setClass(BluetoothChat.this,LLKanActivity.class);
BluetoothChat.this.startActivity(intent);
}
break;