Note that there are some explanatory texts on larger screens.

plurals
  1. POProgressDialog in Android not appearing (incorrect thread handling?)
    text
    copied!<p>I am trying to implement a radio player (using shoutcast streams) for android. What I want to do is, while the radio stream loads in the player, the UI displays a spinning wheel animation. On successful loading (as soon as the song starts playing) the animation disappears.</p> <p>Here is the code that I am using.</p> <pre><code>PlayStopStreamingButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Thread initializer = new Thread(new Runnable() { @Override public void run() { Looper.myLooper(); Looper.prepare(); progressDialog = ProgressDialog.show(RadioPlayerActivity.this, "", "Selecting Radio Station", true); JukefoxApplication.getHandler().post(new Runnable() { @Override public void run() { radioPlayerEventListener.onPlayStopStreamingButtonClicked(); progressDialog.dismiss(); } }); } }); initializer.start(); } }); </code></pre> <p>I don't get any spinning animation. I am almost certain that my mistake lies in incorrect handling of threads. If someone could out the correct way, I would be grateful. </p> <p>EDIT, this seems to work:</p> <pre><code> PlayStopStreamingButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { progressDialog = ProgressDialog.show(RadioPlayerActivity.this, "", "Selecting Radio Station", true); Thread initializer = new Thread(new Runnable() { @Override public void run() { radioPlayerEventListener.onPlayStopStreamingButtonClicked(); progressDialog.dismiss(); } }); initializer.start(); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload