就是对讲机有个按钮,基本上第一次登陆的时候,点击就闪退,第二次之后就会好很多(如果不闪退的情况下,连续使用基本不会闪退),但是偶尔也闪退,退出软件一会,再登陆的时候还是闪退,我实在是搞不明白了,贴上部分代码,求大神赐教!
后台处理: chatButton就是那个点击的按钮
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.chat);
recorder = new AudioRecorder();
int groupId = 0;
audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
onlineNum = (TextView) findViewById(R.id.online_num);
groupName = (TextView) findViewById(R.id.group_name);
name=(TextView)findViewById(R.id.name);
groupPhone=(TextView)findViewById(R.id.leader_phone);
phone = (TextView) findViewById(R.id.phone);
groupOwnerName = (TextView) findViewById(R.id.leader_name);
chatButton = (ImageView) findViewById(R.id.chat_button);
loudSpeaker = (ToggleButton) findViewById(R.id.loudspeaker);
manageButton = (ImageView) findViewById(R.id.manage_button);
micoInfo = (TextView) findViewById(R.id.mico_info);
name.setText(Constant.getCurrentUser().name);
phone.setText(Constant.getCurrentUser().phone);
chatButton.setOnClickListener(this);
chatButton.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_UP:
stopSpeaking();
break;
case MotionEvent.ACTION_DOWN:
TcpWrapper.sendCommand(Constant.TYPE_ROB_MIC);
micoInfo.setText("抢麦中……");
break;
}
return false;
}
});
sendCommand方法:
public static void sendCommand(short messageId)
{
try
{
if (out == null)
{
reconnectSocket();
}
Log.d(TAG, "sendCommand():messageId=" + messageId);
byte[] packet = new byte[3];
System.arraycopy(Utils.getBytes(messageId), 0, packet, 0, 2);
packet[2] = (byte) 0;
out.write(packet);
out.flush();
}
catch (IOException e)
{
Log.e(TAG, "写入服务器数据异常:" + e.getMessage());
//关闭写出流
try
{
if (out != null)
{
out.close();
out = null;
}
}
catch (IOException ie)
{
Log.e(TAG, "关闭写出流异常:" + ie.getMessage());
}
}
catch (NullPointerException e)
{
Log.e(TAG, "写入服务器数据异常:" + e.getMessage());
}
}
logcat中错误就报了一句话:
07-24 14:12:40.938: A/libc(1661): Fatal signal 8 (SIGFPE) at 0x0000067d (code=-6), thread 1934 (Thread-9866)
有懂的大神请帮忙,不胜感激!
还需要什么文件代码请留言!
安卓开发语音对讲机,一点击说话按钮就闪退,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/iasd923/p/3879841.html