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

  • Home
  • SEARCH
  • 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 9198879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:23:35+00:00 2026-06-17T22:23:35+00:00

I would like make a simple application for Android using Bluetooth. So I looked

  • 0

I would like make a simple application for Android using Bluetooth.
So I looked upon some examples on the web and I’ve found one.
However I have an error in my MainActivity.java.
There is only one error but it is not noticed in the ‘console’;
It’s just underlined in red.
Due to this problem, I can’t run the project.

This is my Main :

package com.testbluetooth;

import android.os.Bundle;
import com.testbluetooth.R;
import android.app.Activity;
import android.view.Menu;
import java.util.Set;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.widget.TextView;

public class MainActivity extends Activity 
{
    TextView out;

    // Called when the activity is first created. 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

   @Override
public boolean onCreateOptionsMenu(Menu menu)
{
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;

    //------here the error underlined by Eclipse: -------
    out = (TextView) findViewById(R.id.out);


    // Getting the Bluetooth adapter
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    out.append("\nAdapter: " + adapter);

    // Check for Bluetooth support in the first place 
    // Emulator doesn't support Bluetooth and will return null
    if(adapter==null) 
    { 
        out.append("\nBluetooth NOT supported. Aborting.");
        //return;
    }

    // Starting the device discovery
    out.append("\nStarting discovery...");
    adapter.startDiscovery();
    out.append("\nDone with discovery...");

    // Listing paired devices
    out.append("\nDevices Pared:");
    Set<BluetoothDevice> devices = adapter.getBondedDevices();
    for (BluetoothDevice device : devices) 
    {
        out.append("\nFound device: " + device);
    }
}
}

And this is *activity_main.xml* in the layout :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<TextView
    android:id="@+id/out"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="@string/app_name" />

</RelativeLayout>

The id class in R.java :

public static final class id {
    public static final int menu_settings=0x7f070001;
    public static final int out=0x7f070000;
 }

So It’s with the line out = (TextView) findViewById(R.id.out); that I’ve the problem. I’ve cleaned the project, I tried to create a new xml file in the layout, change out’s name, but nothing.

  • 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-17T22:23:36+00:00Added an answer on June 17, 2026 at 10:23 pm

    Move return true; to the very end of your onCreateOptionsMenu() method so it is just before its closing brace. Eclipse must be complaining about unreachable code.

    I’d also recommend not doing anything else in onCreateOptionsMenu(), this should be only for making the options menu, not modifying a UI element part of the Activity’s layout (in this case, your out TextView).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data in .cvs. I would like to make a simple barplot
i would like make a simple application on iphone had a client and server
I am working on a simple desktop java application. I would like to make
I would like to make a simple project. Having two Android phones, I would
For (JUnit) testing purposes I'd like to make a simple application that would be
I would like to make a simple desktop application to learn this kind of
I would like to make a simple notice / news system for website administrators.
I would like make a script using PHP (probably need JS) to send POST
i am developing an application for android and would like for my users to
I'm trying to make a simple application form were user can input data like

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.