Android-蓝牙连接InputStream关闭导致我的应用程序崩溃

Android-蓝牙连接InputStream关闭导致我的应用程序崩溃,android,exception-handling,bluetooth,android-bluetooth,Android,Exception Handling,Bluetooth,Android Bluetooth,我有一个安卓应用程序,可以连接到蓝牙设备。当我关闭设备时,应用程序尝试断开连接。所以我尝试关闭inputstream、outputstream和套接字。即使我在每次尝试关闭时都有一个try-catch,但当应用程序尝试关闭inputstream时会崩溃。有什么想法吗?代码示例: private void resetConnection() { if (mmInputStream != null) { try { mmInputStream.clos

我有一个安卓应用程序,可以连接到蓝牙设备。当我关闭设备时,应用程序尝试断开连接。所以我尝试关闭inputstream、outputstream和套接字。即使我在每次尝试关闭时都有一个try-catch,但当应用程序尝试关闭inputstream时会崩溃。有什么想法吗?代码示例:

private void resetConnection() {
    if (mmInputStream != null) {
        try {
            mmInputStream.close();
        } catch (Exception e) {
            Log.e(LOG_TAG, "CANNOT CLOSE InputStream", e);
        }
        mmInputStream = null;
    }

    if (mmOutputStream != null) {
        try {
            mmOutputStream.close();
        } catch (Exception e) {
            Log.e(LOG_TAG, "CANNOT CLOSE OutputStream", e);
        }
        mmOutputStream = null;
    }

    if (mmSocket != null) {
        try {
            mmSocket.close();
        } catch (Exception e) {
            Log.e(LOG_TAG, "CANNOT CLOSE mmSocket", e);
        }
        mmSocket = null;
    }

}

有什么建议吗?谢谢

让我们看看stacktrace@NikoYuwono但愿有一条痕迹:(。唯一显示的是:a/libc﹕ 致命信号11(SIGSEGV)在0x00000008(代码=1),线程10912(线程-3466)你能在调用resetConnection()的地方发布代码吗?@NikoYuwono。很抱歉,我不能发布代码的确切部分,但我可以告诉你,当我向设备发送数据时,如果我遇到异常(意味着设备不可用),我可以告诉你然后在捕获时,我调用resetConnection以重置所有内容并再次开始扫描设备。您遇到的崩溃是本机崩溃,这就是为什么try-catch没有捕获到它,所以我怀疑是其他原因导致了此崩溃