Reputation: 1518
While Video Activity is working i'm calling the progressdialog.show()
in OnCreate()
and when mediaplayer.start()
method finish its work, i'm creating a thread and starting it to stop the progressdialog
. Whatever i tried, progressdialog is not appearing even if it works(in debug mod i checked it) in Oncreate()
. I tried AsyncTask
OnPostExecute()
, OnPreExecute
result is still the same : ProgressDialog
is appearing just one second and dismiss. Where am i doing wrong, i couldn't find. Hope I could explain myself.
Thanks in advance.
Tried this :
protected void onCreate(Bundle onSaveInstanceState) {
super.onCreate(onSaveInstanceState);
setContentView(R.layout.activity_video);
progressDialog = ProgressDialog.show(VideoActivity.this, "", "Loading...");
//Codes
}
//Long proccess
void playVideo() {
mMediaPlayer.start();
mMediaPlayer.seekTo(length);
Thread th = new Thread(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
}
});
th.start();
}
And this :
class RequestTask extends AsyncTask<String, String, String> {
private ProgressDialog dialog = new ProgressDialog(VideoActivity.this);
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog.setMessage("Loading..."); // Yükleniyor // mesajı // veriyoruz
dialog.show();
dialog.setCancelable(false);
}
//DoingBackground()..
protected void onPostExecute(String result) {
dialog.dismiss();
}
Upvotes: 0
Views: 327
Reputation: 33
If you use
progressDialog.dismiss();
inside run() it will disappear when thread starts.
Upvotes: 1