安卓開發語音對講機,一點擊說話按鈕就閃退

來源:互聯網
上載者:User

標籤:使用   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)


有懂的大神請幫忙,不勝感激!
還需要什麼檔案代碼請留言!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.