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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:42:39+00:00 2026-06-06T04:42:39+00:00

I am developing an application which has around 8 Activities, and a class which

  • 0

I am developing an application which has around 8 Activities, and a class which is used to connect/receive data to/from an embedded Bluetooth chip. When I started, a Bluetooth object was initialized in my initial Activity, where there was a Handler which received messages from the Bluetooth object.

After poking around on the internet for a while, it seems like the best idea for me is to turn my class into an Application subclass. However, doing this removes the need for me to initialize an object in the MainMenu, which removes my ability to pass it the Handler used.

Does anyone know of a way to eliminate the need for a Handler, so that every time the Bluetooth Application changes it state or receives data, the current Activity can access it?

My main problem with this approach is that the Activity doesn’t know when the Bluetooth Application will be sending it messages, the Application waits and listens, and then notifies the Activity when it happens.

OR

Is it bad practice for me to write the Handler into the MainMenu, have it handle messages for ALL the different activities, and then pass the Handler from Activity to Activity?

  • 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-06T04:42:43+00:00Added an answer on June 6, 2026 at 4:42 am

    I’m going to assume that you’re trying to achieve the following as it’s a little unclear from your question your ultimate aim (sorry!):

    1. Your application has several activities but only one Activity receives the data from the bluetooth device.
    2. The other activities in in your application require the data from the bluetooth device but are not receiving it directly from the bluetooth device. Currently you’re providing the data via the one activity mentioned above.
    3. You want to NOT use a Handler to achieve this.

    If my above assumptions are correct then you are going along the correct lines but you probably do not want to use a Handler.

    You are quite correct in having one Activity handle all the interactions with the Bluetooth device. It simplifies things and provides a much better, cleaner way of handling the Bluetooth device. However you need to get the data from this one Activity to all the others and to achieve this you would probably want to use Broadcasts, BroadcastReceivers and Intents. See here for an overview.

    However if you can you might want to take a look at using LocalBroadcastManager as this keeps any broadcasts within your own app’s space. Broadcasts are global and should be avoided if you do not need to pass the data outside of your own app due to security implications.

    Finally, have you considered using Fragments for your other Activities? Another disadvantage with Broadcasts is there is extra overhead associated with them. If you’re keeping data within your app then you can create an interface to be implemented by each of your Fragments and your main activity just calls that interface on the Fragment that is currently selected.

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

Sidebar

Related Questions

I am developing a simple application which has to send an SMS message from
I am developing an asp.net mvc application, which has these enity classes: public class
I`m developing an application which receives data from my GPS device like coordinates, speed
Our company is developing a new application, which has a somewhat large business data
I am developing an application which has about 8000 names of the cities of
I am developing an iPhone application which has a module written in C and
Im Developing a web application which is very critical. So authentication has to be
I am developing a Silverlight application which has a list <ListBox x:Name=_list_collection SelectionChanged=SelectionChanged ScrollViewer.VerticalScrollBarVisibility=Auto
I'm developing an application which has a Settings pane, following the AppPrefs sample by
I'm developing an application which has two main 'parts' to it... The public facing

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.