蓝牙聊天"在样品code&QUOT错误; [英] Error in the sample code "bluetooth chat"

查看:147
本文介绍了蓝牙聊天"在样品code&QUOT错误;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行从开发商的网站上的蓝牙聊天的样本,但它不能成为run..i从现有源的新项目,我打开,但它含有大量的errors..any想法,请??? http://developer.android.com/resources/samples/BluetoothChat/index.html

i m trying to run the bluetooth chat sample from the developers site but it cant be run..i create a new project from existing source,i opens but it contains lots of errors..any idea please??? http://developer.android.com/resources/samples/BluetoothChat/index.html

我取代了match_parent与FILL_PARENT,而现在的控制台消息是:

i replaced the "match_parent" with "fill_parent", and now the console message is:

[2011-03-24 13:29:17 - BluetoothChat] W/ResourceType( 5892): Bad XML block: header size 60 or total size 3932356 is larger than data size 0
[2011-03-24 13:29:17 - BluetoothChat] C:\Users\kostas\Desktop\BluetoothChat\res\menu\option_menu.xml:17: error: No resource identifier found for attribute 'showAsAction' in package 'android'
[2011-03-24 13:29:17 - BluetoothChat] C:\Users\kostas\Desktop\BluetoothChat\res\menu\option_menu.xml:21: error: No resource identifier found for attribute 'showAsAction' in package 'android'
[2011-03-24 13:29:17 - BluetoothChat] C:\Users\kostas\Desktop\BluetoothChat\res\menu\option_menu.xml:25: error: No resource identifier found for attribute 'showAsAction' in package 'android'

我擦除行安卓showAsAction =ifRoom | withText在option_menu.xml,现在有在console..there没有消息是红色的错误在bluetoothchat.java:

i erased the line android:showAsAction="ifRoom|withText" in the option_menu.xml , and now there is no message in the console..there is red error in the bluetoothchat.java :

private final void setStatus(int resId) {
        final **ActionBar** actionBar = **getActionBar()**;
        actionBar.setSubtitle(resId);
    }

    private final void setStatus(CharSequence subTitle) {
        final **ActionBar** actionBar = getActionBar();
        actionBar.setSubtitle(subTitle);
    }

和在bluetoothChatServise:

and in bluetoothChatServise:

 public AcceptThread(boolean secure) {
            BluetoothServerSocket tmp = null;
            mSocketType = secure ? "Secure":"Insecure";

            // Create a new listening server socket
            try {
                if (secure) {
                    tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                        MY_UUID_SECURE);
                } else {
                    tmp = **mAdapter.listenUsingInsecureRfcommWithServiceRecord**(
                            NAME_INSECURE, MY_UUID_INSECURE);
                }
            } catch (IOException e) {
                Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
            }
            mmServerSocket = tmp;
        }

在这里

public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(
                    MY_UUID_SECURE);
        } else {
            tmp = **device.createInsecureRfcommSocketToServiceRecord**(
                    MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
}

(红色是**之间)

(the red is between the ** ** )

推荐答案

这些API创建不安全RFCOMM只能从API级别10(安卓2.3.3) 而动作条API只能从安卓3.0或API级别11

The APIs for Creating Insecure RFCOMM is available only from API Level 10 (Android 2.3.3) and the ActionBar API is available only from Android 3.0 or API Level 11

这篇关于蓝牙聊天"在样品code&QUOT错误;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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