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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:07:06+00:00 2026-05-21T17:07:06+00:00

My App recieves a neverending datastream from a bluetooth device. I am reading this

  • 0

My App recieves a neverending datastream from a bluetooth device.
I am reading this stream in a while(true) loop and can see the read data in my log.
The problem is, that my device is not responding anymore. Is there a (hopefully) simple way to let the application read the stream in the background?

Thanks!
Christian.

@boulder:
Sorry, I don’t really understand that AsynkTask class. 🙁
Can you please help me with this code putting it in the background?
Thank you very much!

                try {
                while (true) 
                {               
                    read = isBT.read(msgBuffer);
                    connected = true;
                    StringBuilder strBuffer = new StringBuilder();
                    for (int i = 0; i<read; i++) 
                    {
                        int b = msgBuffer[i];
                        strBuffer.append(b);
                    }
                    Log.d(TAG,"++++++ Read "+ read + " Bytes: " + strBuffer.toString());
                }
            }
                catch (IOException e) {
                    Log.d(TAG," +++ IOException ++++", e);
                }
  • 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-21T17:07:07+00:00Added an answer on May 21, 2026 at 5:07 pm

    May be this will be helpful http://android-developers.blogspot.com/2009/05/painless-threading.html

    Handler example:

    private static final String CONTENT_TAG = "content";
    
    // Call this from datastream thread to post data 
    private void postProgress(String aBufferContent) {
        // Wrapping data in bundle
        final Bundle bundle = new Bundle();
        bundle.putString(CONTENT_TAG, aBufferContent);
    
        // Sending message to handler
        final Message message = mProgressHandler.obtainMessage();
        message.setData(bundle);
        mProgressHandler.sendMessage(message);
    }
    
    // This will be executed in UI thread. Do you GUI update job here
    private final Handler mProgressHandler = new Handler() {
        public void handleMessage(Message msg) {
            final String streamContent = msg.getData().getString(CONTENT_TAG);
            myTextView.setText(streamContent);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app uses a WebRequest at certain points to get pages from itself. This
I have a little logging app (written in wxPython) that receives data from a
My app needs to build a buffer from all the selected cells on a
I'm currently trying to port an app from asp.net to php, however I just
In my app, a user can select an image, change the picture of a
My app has many controls on its surface, and more are added dynamically at
An app I'm writing always crashes on a clients computer, but I don't get
My app is installed via NSIS. I want the installer to install the program
My app keeps track of the state of about 1000 objects. Those objects are
Our app (already deployed) is using an Access/Jet database. The upcoming version of our

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.