0

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

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

menu_on_top
  • 2,613
  • 14
  • 44
  • 71

1 Answers1

3

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

Dennis Mathews
  • 6,897
  • 2
  • 26
  • 39
  • hi dennis mathews..i am developing the same from here http://developer.android.com/resources/samples/BluetoothChat/index.html and running the application in v 2.2 mobile but there is same problem so now what should i do for that ?is there any sample running code available for api 6 and above ? – shyam Feb 13 '12 at 06:33