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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:44:59+00:00 2026-06-15T20:44:59+00:00

I am developing an android application where I receive eeg signal from bluetooth and

  • 0

I am developing an android application where I receive eeg signal from bluetooth and display it in real time using achartengine. I use an async task to display the chart and update it. But, I get ConcurrentModificationException everytime. The graph is displayed for sometime and then it gives that error. Below is my code.

mstart.setOnClickListener(new OnClickListener() {

         @Override
        public void onClick(View arg0) 
        {
            // TODO Auto-generated method stub
            // tv.setText("Fetal Heart rate loading..");

//               index = 0;
                flag = true;  



             if(fhr_alg!=null)
                    fhr_alg = null;

             fhr_alg = new AddStringTask();

             algo_done = false;
             /*curr = 5;
             counter = 0;*/
////                a1.setFlag(true);
                //a1.setMax(0);


            Thread tt = new Thread()
            {
                public void run()
                {
                    try{
                        sleep(600);                             
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }finally{

                        fhr_alg.execute();

                    }
                }
            };tt.start();
             if (view_eeg1== null) {
                    LinearLayout layout_eeg1 = (LinearLayout) findViewById(R.id.layout2);
                    view_eeg1= ChartFactory.getLineChartView(BluetoothConnect.this, eeg1, renderer_eeg1);
                  //  layout_eeg1.
                    layout_eeg1.addView(view_eeg1);
                    } else {
                    view_eeg1.repaint();}
            // w1.loadUrl("javascript:callJS()");               
             mstart.setEnabled(false);


        }           
    });



class AddStringTask extends android.os.AsyncTask<Void, Integer, Integer> {
    @Override
    protected void onPostExecute(Integer result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);
        algo_done=true;
        //Toast.makeText(Html.this, "Done Algo !", Toast.LENGTH_SHORT).show();
    }

    @SuppressLint("UseValueOf")
    @Override
    protected Integer doInBackground(Void... unused) {


        try {
            for(int r=0;r<=5000;r++){
                //Thread.sleep(300); 

                series1.add(r,data[r]);
              //  w2.loadUrl("javascript:count(\""+data[r]+"\")"); 

                if(r<=250){
                    renderer_eeg1.setXAxisMax(250);
                }
                else if(r>250){
                    double maxX = series1.getMaxX();
                    double minX = maxX - 250;
                    renderer_eeg1.setXAxisMin(minX);
                    renderer_eeg1.setXAxisMax(maxX);
                }
                view_eeg1.repaint();                   
                publishProgress((int)data[r]);
                SystemClock.sleep(600);

            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 


        return (0);

    }

    @Override
    protected void onProgressUpdate(Integer ... value) {


        int fhr=value[0];
        view_eeg1.repaint();
        w2.loadUrl("javascript:count(\""+fhr+"\")");            
        //a1.setfhr(curr, fhr);
        //curr++;           


    }

}

can anyone tell me why am I getting this error and how to solve it.
Thanks

  • 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-15T20:45:00+00:00Added an answer on June 15, 2026 at 8:45 pm

    problem updating the UI into a Thread that is not an UI Thread so u
    have to use a doinbackground as below and remove the code that
    modifies the UI in doInbackground

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

Sidebar

Related Questions

I'm currently developing an Android application which needs to receive data from a bluetooth
I'm developing a WCF JSON Web Service which receive data from an Android application.
I am developing android application in which i have to open option menu from
I am developing an android application that receives data about events from a server.
I'm developing Android application using third party libraries (Twitter4j). I want to be able
im developing an Android application for twitter that will sync data coming from the
I am developing an Android application which needs an image to be transmitted from
I'm developing an android application.I'm using Android SDK 2.2 I'm using 2 Broadcast receivers.
I am developing one application for reading sensor data from an Android device through
I am currently developing an application that receives GPS data gathered using and android

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.