0

I would like to display a toast While there are background audiorecord tasks running.

Right now I have something like this which displays a toast with an image in it just fine:

...onCreate(){
        mHandler = new Handler();

//Toast Setup
        LayoutInflater myInflater=LayoutInflater.from(this);
        View view=myInflater.inflate(R.layout.toast_layout,null);
        mytoast=new Toast(this);
        mytoast.setView(view);
        mytoast.setGravity(0, 1, 1);
        mytoast.setDuration(Toast.LENGTH_LONG);
}


//HANDLER STUFF
     final Runnable mUpdateResults = new Runnable() {
          public void run() {
            mytoast.show();
        }
        };

... onClick(){
audiorecordingtasks();
mHandler.post(mUpdateResults);

}

However, if I put mHandler.post(mUpdateResults); before my audiorecord tasks it waits until after the audiorecord task to finish before it displays it.

Anyone know how to display it before and DURING the audiorecord task?

Killer Penguin
  • 194
  • 1
  • 11

2 Answers2

1

Here look there is the answer....

Can an Android Toast be longer than Toast.LENGTH_LONG?

Community
  • 1
  • 1
Android
  • 427
  • 5
  • 14
  • Thanks for the suggestion, though I don't know if I need all that. I'm just looking to display a sign that says yes it's actively recording now with the toast seemed to be the easiest way. The handler was just playing around getting used to it. I just want to know how to get the toast fixed for now so it shows before audiorecordingtasks(); – Killer Penguin Jan 14 '14 at 22:31
  • why do you use complex toast just for using to display string thats says "RECORDING"?? if you only display string use the toast like this `Toast toast = Toast.makeText(context, text, duration).show;` – Android Jan 14 '14 at 22:40
  • No, It's still doesn't show while the audiorecord task is running. – Killer Penguin Jan 27 '14 at 00:50
0

You should access the toast methods in a static way such as this:

Toast.makeText(this, "TExt i want to display", Toast.LENGTH_LONG).show();
Ricky
  • 258
  • 2
  • 11