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 6247139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:48:55+00:00 2026-05-24T12:48:55+00:00

I am making an android application and i am confused in this section of

  • 0

I am making an android application and i am confused in this section of the code. I am integrating bluetooth and making a call to startApp in the previous class. I want to show these buttons on the main page when startApp is called. From my understanding This is how I would go about doing this? Why Can’t I do this? When i try to do this, eclipse doesn’t let me. How would i change the code so that i could set up the main menu start page like shown below?

Thanks!!

main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/background"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="85dip" 
    android:orientation="horizontal">
    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_gravity="center" android:orientation="vertical">
        <TextView 
            android:text="@string/mainTitle"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_gravity="center"
            android:layout_marginBottom="25dip"
            android:textSize="24.5sp"/>


        <!-- Patient Option -->
        <Button android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:layout_weight="1"
            android:text="@string/patientButton"
            android:id="@+id/patientButton">
        </Button>

        <!-- Doctor Option -->
        <Button android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/doctorButton"
            android:layout_weight="1"
            android:id="@+id/doctorButton">
        </Button>

        <!-- Exit Mode -->
        <Button android:text="@string/exit" 

         android:layout_weight="1"
         android:id="@+id/exit" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content"></Button>

         <!-- About Mode -->
        <Button android:text="@string/aboutButton" 

         android:layout_weight="1"
         android:id="@+id/aboutButton" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content"></Button>

    </LinearLayout>



</LinearLayout>



    package com.joshi.remotedoc;

import com.joshi.remotedoc.DeviceList;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;


public class Remote_DocActivity extends Activity implements OnClickListener {    
    /** Called when the activity is first created. */
    //private static final String TAG = "Remote_Doc";
    private static final String TAG = "BluetoothChat";
    private static final boolean D = true;
    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;
    private BluetoothAdapter mBluetoothAdapter = null;
    private String mConnectedDeviceName = null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(D) Log.e(TAG, "+++ ON CREATE +++");
        setContentView(R.layout.main);



        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        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.
        if (!mBluetoothAdapter.isEnabled()) {
            Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
            } 
        else {
            startApp();
            }
        }

    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);
            }
        }
    private void startApp(){

        View Patient_Button = findViewById(R.id.patientButton);
        Patient_Button.setOnClickListener(this);
        Patient_Button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent b = new Intent(this, Detailed_ModeActivity.class);
                startActivity(b);
                break;
                }
            }
        );
        View Doctor_Button = findViewById(R.id.doctorButton);
        Doctor_Button.setOnClickListener(this);
        View About_Option = findViewById(R.id.aboutButton);
        About_Option.setOnClickListener(this);
        View Exit_Option = findViewById(R.id.exit);
        Exit_Option.setOnClickListener(this);



    }

    /*private final Handler mHandler = new Handler() {
        @Override
        public void handleData(Data data) {

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

    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.patientButton:
            Intent b = new Intent(this, Detailed_ModeActivity.class);
            startActivity(b);
            break;
        case R.id.doctorButton:
            Intent a = new Intent(this, Detailed_ModeActivity.class);
            startActivity(a);
            break;
        case R.id.aboutButton:
            Intent i = new Intent(this, About.class);
            startActivity(i);
            break;
        case R.id.exit:
            finish();
            break;
        }

    }   


}
  • 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-05-24T12:48:56+00:00Added an answer on May 24, 2026 at 12:48 pm

    Instead of:

    Intent b = new Intent(this, Detailed_ModeActivity.class);
    

    Try this:

    Intent b = new Intent(getApplicationContext(), Detailed_ModeActivity.class);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new android developer and I am currently making an application to
I am making an android application that shows a list with users, I would
I am making an Android application. Since it is so simple, I first thought
I am making an HTTP get request to a website for an android application
I'm making my first Android application. As a toy problem to learn the system
I'm making a media player application in android where one part of my screen
I am making a IM client for android and i want to know how
I'm thinking about making a networked game. I'm a little new to this, and
I have been making a little toy web application in C# along the lines
I am trying to write an android application and my workflow is as follows:

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.