更新Android 4.2.2后蓝牙流停止。 4.4.2 [英] Bluetooth stream stopped after updating Android 4.2.2. to 4.4.2

查看:161
本文介绍了更新Android 4.2.2后蓝牙流停止。 4.4.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发Android应用程序,它不断地从医疗设备接收数据。设备配置为串行COM端口。

I'm developing Android application, which is continuously receiving data from medical device. Device configured as Serial Com port.

在Android 4.2.2一切正常。更新华硕K00E到Android 4.4.2之后出现了问题。

On android 4.2.2 everything is Ok. After updating Asus K00E to Android 4.4.2 there was a problem.

连接装置后立即开始发送数据。
几秒钟华硕接收数据正常,然后停止。
在日志中没有错误。

After connecting device immediately begins transmitting data. For several seconds Asus receives data normally, then stops. No errors in logs.

视频在这里:
http://youtu.be/GEc3yKVQGJc

,请注意最后几秒钟。

连接片段:

    protected Void ConnectToCardioBT(BluetoothDevice device) {
    try {
        Method m = null;
        try {
            m = device.getClass().getMethod("createRfcommSocket",
                    new Class[] { int.class });
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        try {
            socket = (BluetoothSocket) m.invoke(device, Integer.valueOf(1));
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        socket.connect();

...............

..........................

从流片段阅读:

    private class ConnectedThread extends Thread {
    private final InputStream mmInStream;

    public ConnectedThread(BluetoothSocket socket) {
        InputStream tmpIn = null;
        try {
            tmpIn = socket.getInputStream();
        } catch (IOException e) {
        }
        mmInStream = tmpIn;
    }

    public void run() {

        byte[] buffer = new byte[2048];
        int bytes; 

        while (true) {
            try {

                Log.d(TAG,Integer.toString(mmInStream.available())+": " + new Date().getTime());
                bytes = mmInStream.read(buffer);

...............................

...............................

任何帮助是极大的AP preciated。

Any assistance is greatly appreciated.

推荐答案

溶液这里找到:

<一个href=\"http://stackoverflow.com/questions/18420525/application-using-bluetooth-spp-profile-not-working-after-update-from-android-4?rq=1\">Application从使用的Andr​​oid 4.2更新后无法正常工作蓝牙SPP配置文件到Android 4.3

对于一些未知的原因,它是需要一些命令发送到定期发射装置。在这种情况下,传送不停止。如果有人知道的原因,请评论。谢谢你。

For some unknown reason, it is needed to transmit some command to transmitting device periodically. In this case, the transfer is not stopped. If anyone knows the reason, please comment. Thanks.

这篇关于更新Android 4.2.2后蓝牙流停止。 4.4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆