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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:17:50+00:00 2026-05-27T16:17:50+00:00

I am developing an application to communicate with a device via bluetooth. Same as

  • 0

I am developing an application to communicate with a device via bluetooth.
Same as the BluetoothChat sample, my application makes a service object, and call service.connect() to get a connectedThread for data transmission.

and I have a command method, which takes an integer as its parameter.

the problem is, sometimes, that device returns invalid data.
So when I want to execute the command with ten different parameter, I need to do something like :

for (i = 0; i < 10; i++) {
    myService.write(command(i)); 
    packet = waitForResponse(myService);

    if (packet is valid) {
        do something;
    } else {
        i--;
    }  
}

My program is using handler to deal messages, e.g. when the connectedThread read some data, it will

mHandler.obtainMessage(ControlActivity.MESSAGE_READ, -1, -1, data)
                         .sendToTarget();

And there is a handler in my Activity class to deal with these messages.

How can I do something like “waitForResponse” on Android?
or Is there any other way to meet my requirement?

API Level: 13

  • 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-27T16:17:51+00:00Added an answer on May 27, 2026 at 4:17 pm

    Instead of waiting, run your activity normally and just listen from broadcasts from the service.

    From the service class send a global broadcast when new data is ready, and have the activity class listen and respond for that particular message.

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

Sidebar

Related Questions

I am developing an application which uses an xmlrpc service to communicate. I developed
Hi i am developing android application. I am using web service to communicate with
The application I'm developing communicates with an digital audio device, which is capable of
I'm currently developing an application that is comprised of five separate executables that communicate
I am developing a Cocoa application which communicates constantly with a web service to
I'm developing a PC c++ application running on windows. The application shall communicate with
We have plans of developing a web application that will have to communicate with
I'm developing a Win32 mobile application (.NET CF 2.0/3.5) that has to communicate with
I'm developing an application that will need to communicate with itself running on different
I am developing a windows service application and I'm running into a problem concerning

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.