开发者

Error in the sample code "bluetooth chat"

i m trying开发者_StackOverflow 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

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'

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);
    }

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;
        }

and here

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 ** ** )


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜