Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:50:58+00:00 2026-06-14T05:50:58+00:00

I have modified an example bluetooth communication app from http://www.elektor.com/magazines/2012/march/android-switch-interface.2084156.lynkx to make it sync

  • 0

I have modified an example bluetooth communication app from http://www.elektor.com/magazines/2012/march/android-switch-interface.2084156.lynkx to make it sync with my Arduino.

After doing some minor changes (button instead if seekbar), I cannot get it to run. I get FC on my phone and errors as attached below.

Im new to android/java but have been programming for years.

I cannot seem to fix it from searching the web for 2 days.

11-13 18:41:58.127: E/AndroidRuntime(21448): java.lang.RuntimeException: Unable to start activity     ComponentInfo{www.elektor.BTInterface/www.elektor.BTInterface.BluetoothChat}:    android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2185)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.os.Looper.loop(Looper.java:137)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.ActivityThread.main(ActivityThread.java:4906)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at java.lang.reflect.Method.invokeNative(Native Method)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at java.lang.reflect.Method.invoke(Method.java:511)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at dalvik.system.NativeStart.main(Native Method)
11-13 18:41:58.127: E/AndroidRuntime(21448): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title  features
11-13 18:41:58.127: E/AndroidRuntime(21448):    at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:227)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2604)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2844)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:252)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.Activity.setContentView(Activity.java:1867)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at www.elektor.BTInterface.BluetoothChat.onCreate(BluetoothChat.java:101)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.Activity.performCreate(Activity.java:5008)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-13 18:41:58.127: E/AndroidRuntime(21448):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2139)
11-13 18:41:58.127: E/AndroidRuntime(21448):    ... 11 more
11-13 18:42:02.872: I/Process(21448): Sending signal. PID: 21448 SIG: 9

This is my code and xmls

/**
 * This is the main Activity that displays the current chat session.
 */
public class BluetoothChat extends Activity {
    // Debugging
    private static final String TAG = "BluetoothChat";
    private static final boolean D = true;

    // Message types sent from the BluetoothChatService Handler
    public static final int MESSAGE_STATE_CHANGE = 1;
    public static final int MESSAGE_READ = 2;
    public static final int MESSAGE_WRITE = 3;
    public static final int MESSAGE_DEVICE_NAME = 4;
    public static final int MESSAGE_TOAST = 5;

    // Key names received from the BluetoothChatService Handler
    public static final String DEVICE_NAME = "device_name";
    public static final String TOAST = "toast";

    // Intent request codes
    private static final int REQUEST_CONNECT_DEVICE_SECURE = 1;
    private static final int REQUEST_CONNECT_DEVICE_INSECURE = 2;
    private static final int REQUEST_ENABLE_BT = 3;

    // Layout Views
    private TextView mTitle;
    private ListView mConversationView;
    private EditText mOutEditText;

    private WakeLock  w1;

    private String mConnectedDeviceName = null;
    // Array adapter for the conversation thread
    private ArrayAdapter<String> mConversationArrayAdapter;
    // String buffer for outgoing messages
    private StringBuffer mOutStringBuffer;
    // Local Bluetooth adapter
    private BluetoothAdapter mBluetoothAdapter = null;
    // Member object for the chat services
    private BluetoothRfcommClient mChatService = null;
  //  Activity mContext = null;

    private int Servo1;
    private int Servo2;

    private int maxServo=120;
    private Button sButton1;
    private Button sButton2;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(D) Log.e(TAG, "+++ ON CREATE +++");

        // Set up the window layout
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.main);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

        // Set up the custom title
        mTitle = (TextView) findViewById(R.id.title_left_text);
        mTitle.setText(R.string.app_name);
        mTitle = (TextView) findViewById(R.id.title_right_text);
        sButton1 = (Button) findViewById(R.id.button1);
        sButton2 = (Button) findViewById(R.id.button2);
        // Get local Bluetooth adapter
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();


        // If the adapter is null, then Bluetooth is not supported
        if (mBluetoothAdapter == null) {
            Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
            finish();
            return;
        }

    } 


    @Override
    public void onStart() {
        super.onStart();
        if(D) Log.e(TAG, "++ ON START ++");
        // If BT is not on, request that it be enabled.
        // setupChat() will then be called during onActivityResult
        if (!mBluetoothAdapter.isEnabled()) {
            Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
        // Otherwise, setup the chat session
        } else {
            if (mChatService == null) setupChat();
        }
    }

    @Override
    public synchronized void onResume() {
        super.onResume();
        if(D) Log.e(TAG, "+ ON RESUME +");
        // Performing this check in onResume() covers the case in which BT was
        // not enabled during onStart(), so we were paused to enable it...
        // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
        if (mChatService != null) {
            // Only if the state is STATE_NONE, do we know that we haven't started already
            if (mChatService.getState() == BluetoothRfcommClient.STATE_NONE) {
              // Start the Bluetooth chat services
              mChatService.start();
            }
        }
    }

    private void setupChat() {
        Log.d(TAG, "setupChat()");

        // Initialize the array adapter for the conversation thread
        mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
        mConversationView = (ListView) findViewById(R.id.in);
        mConversationView.setAdapter(mConversationArrayAdapter);



        // Initialize the BluetoothChatService to perform bluetooth connections
        mChatService = new BluetoothRfcommClient(this, mHandler);

        // Initialize the buffer for outgoing messages
        mOutStringBuffer = new StringBuffer("");
    }

    @Override
    public synchronized void onPause() {
        super.onPause();
        if(D) Log.e(TAG, "- ON PAUSE -");
        //w1.release();
    }

    @Override
    public void onStop() {
        super.onStop();
        if(D) Log.e(TAG, "-- ON STOP --");

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        // Stop the Bluetooth chat services
        if (mChatService != null) mChatService.stop();
        if(D) Log.e(TAG, "--- ON DESTROY ---");
    }

    private void ensureDiscoverable() {
        if(D) Log.d(TAG, "ensure discoverable");
        if (mBluetoothAdapter.getScanMode() !=
            BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
            Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
            discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
            startActivity(discoverableIntent);
        }
    }

    /**
     * Sends a message.
     * @param message  A string of text to send.
     */
    private void sendMessage(String message) {
        // Check that we're actually connected before trying anything
        if (mChatService.getState() != BluetoothRfcommClient.STATE_CONNECTED) {

            Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT).show();

            return;
        }
        // Check that there's actually something to send
        if (message.length() > 0) {
            // Get the message bytes and tell the BluetoothChatService to write
            byte[] send = message.getBytes();
            mChatService.write(send);

            // Reset out string buffer to zero and clear the edit text field
            mOutStringBuffer.setLength(0);
            mOutEditText.setText(mOutStringBuffer);
        }
    }

    // The action listener for the EditText widget, to listen for the return key

    // The Handler that gets information back from the BluetoothChatService
    private final Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case MESSAGE_STATE_CHANGE:
                if(D) Log.i(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
                switch (msg.arg1) {
                case BluetoothRfcommClient.STATE_CONNECTED:
                    mTitle.setText(R.string.title_connected_to);
                    mTitle.append(mConnectedDeviceName);
                    mConversationArrayAdapter.clear();
                    break;
                case BluetoothRfcommClient.STATE_CONNECTING:
                    mTitle.setText(R.string.title_connecting);
                    break;
                //case BluetoothRfcommClient.STATE_LISTEN:
                case BluetoothRfcommClient.STATE_NONE:
                    mTitle.setText(R.string.title_not_connected);
                    break;
                }
                break;
            case MESSAGE_WRITE:
                byte[] writeBuf = (byte[]) msg.obj;
                // construct a string from the buffer
                String writeMessage = new String(writeBuf);
                mConversationArrayAdapter.add("Me:  " + writeMessage);
                break;
            case MESSAGE_READ:
                byte[] readBuf = (byte[]) msg.obj;
                // construct a string from the valid bytes in the buffer
                String readMessage = new String(readBuf, 0, msg.arg1);
                mConversationArrayAdapter.add(mConnectedDeviceName+":  " + readMessage);
                UpdateScreen(readMessage);
                // INSERT READING SWICTH 

                break;
            case MESSAGE_DEVICE_NAME:
                // save the connected device's name
                mConnectedDeviceName = msg.getData().getString(DEVICE_NAME);
                Toast.makeText(getApplicationContext(), "Connected to "
                               + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
                break;
            case MESSAGE_TOAST:
                Toast.makeText(getApplicationContext(), msg.getData().getString(TOAST),
                               Toast.LENGTH_SHORT).show();
                break;
            }
        }
    };

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(D) Log.d(TAG, "onActivityResult " + resultCode);
        switch (requestCode) {
        case REQUEST_CONNECT_DEVICE_SECURE:
            // When DeviceListActivity returns with a device to connect
            if (resultCode == Activity.RESULT_OK) {
                connectDevice(data, true);
            }
            break;
        case REQUEST_CONNECT_DEVICE_INSECURE:
            // When DeviceListActivity returns with a device to connect
            if (resultCode == Activity.RESULT_OK) {
                connectDevice(data, false);
            }
            break;
        case REQUEST_ENABLE_BT:
            // When the request to enable Bluetooth returns
            if (resultCode == Activity.RESULT_OK) {
                // Bluetooth is now enabled, so set up a chat session
                setupChat();
            } else {
                // User did not enable Bluetooth or an error occured
                Log.d(TAG, "BT not enabled");
                Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    }

    private void connectDevice(Intent data, boolean secure) {
        // Get the device MAC address
        String address = data.getExtras()
            .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
        // Get the BLuetoothDevice object
        BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
        // Attempt to connect to the device
        mChatService.connect(device);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.option_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Intent serverIntent = null;
        switch (item.getItemId()) {
        case R.id.secure_connect_scan:
            // Launch the DeviceListActivity to see devices and do scan
            serverIntent = new Intent(this, DeviceListActivity.class);
            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE);
            return true;
        case R.id.insecure_connect_scan:
            // Launch the DeviceListActivity to see devices and do scan
            serverIntent = new Intent(this, DeviceListActivity.class);
            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_INSECURE);
            return true;
        case R.id.discoverable:
            // Ensure this device is discoverable by others
            ensureDiscoverable();
            return true;
        }
        return false;
    }
        private void UpdateScreen(String txtMessage) {
   }
        public void onServoButtonClick(View view) {
            switch (view.getId()){
            case R.id.button1:
                if (Servo1 < maxServo){
                    Servo1++;
                    sendMessage("P,"+Servo1);
                }
            case R.id.button2:
                if (Servo1 > 0){
                    Servo1--;
                    sendMessage("P,"+Servo1);
                }
         }  
         }
    }   



<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/GridLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="2"
    android:orientation="horizontal" >

    <ListView
        android:id="@+id/in"
        android:layout_height="62dp"
        android:layout_column="0"
        android:layout_gravity="fill_horizontal"
        android:layout_row="0"
        android:stackFromBottom="true"
        android:transcriptMode="alwaysScroll" />

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_column="0"
        android:layout_gravity="left"
        android:layout_row="1"
        android:text="@string/servo_1_up" />

    <Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_column="0"
        android:layout_gravity="left"
        android:layout_row="2"
        android:text="@string/servo_1_down" />

</GridLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:versionCode="1"
      android:versionName="1.0" package="www.elektor.BTInterface">
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>

    <application android:label="@string/app_name"
                 android:icon="@drawable/app_icon" >
        <activity android:name=".BluetoothChat"
                  android:label="@string/app_name"
                  android:configChanges="orientation|keyboardHidden" android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="www.elektor.BTInterface.DeviceListActivity"
                  android:label="@string/select_device"
                  android:theme="@android:style/Theme.Dialog"
                  android:configChanges="orientation|keyboardHidden" />
    </application>
</manifest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:51:00+00:00Added an answer on June 14, 2026 at 5:51 am

    I can duplicate the crash report when I raise the minimum SDK to 16. So return the minSdkVersion to 6 in your Manifest:

    <uses-sdk android:minSdkVersion="6" android:targetSdkVersion="16" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have modified example connected-lists from jquery site http://jqueryui.com/sortable/#connect-lists below: <!doctype html> <html lang=en>
I have modified my etc/hosts file (under Windows 7), so that www.example.com and demo.example.com
I've modified the bluetooth chat example from the SDK demos to be able to
1) I have a Drupal site located at http://example.com and I have a directory
I have modified the guestbook example shipped with google app engine (java) to include
I have used BluetoothChatService class from BluetoothChat example program for bluetooth connection. I have
I have this modified code example I took from the wikipedia article on anonymous
I have modified this example from the SDK pages to grab all the Contact
I have a modified textbook example as follows (the book is Understanding Ada---a software
I have modified my treeview to look like an Org chart using the example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.