標籤:使用 os 檔案 io 資料 cti 代碼 ar
就是對講機有個按鈕,基本上第一次登陸的時候,點擊就閃退,第二次之後就會好很多(如果不閃退的情況下,連續使用基本不會閃退),但是偶爾也閃退,退出軟體一會,再登陸的時候還是閃退,我實在是搞不明白了,貼上部分代碼,求大神賜教!
幕後處理: 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)
有懂的大神請幫忙,不勝感激!
還需要什麼檔案代碼請留言!