Reputation: 1287
i have onPostExecute in Asynctask
protected void onPostExecute(Void unused) {
TextView tvStatus=(TextView) layoutSendDialog.findViewById(R.id.tvPupukSendStatus);
if (bNodata){
tvStatus.setText("No data to be sent!!!");
}else {
if (bError){
tvStatus.setText("Fail at record #"+String.format("%d",recordCount));
}
else {
tvStatus.setText("Sending Data : Finished");
CUtilities.showAlert(CInputHamaApp.this, "Data Terkirim");
createDialogSend2();
// Closing dashboard screen
}
}
// dismissDialog(CGeneral.DIALOG_SEND);
}
here is my dialog
private Dialog createDialogSend2(){
AlertDialog.Builder builder = new AlertDialog.Builder(CInputHamaApp.this);
builder.setMessage("Anda yakin untuk update?");
builder.setTitle("Warning") ;
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
Intent i2 = new Intent(CInputHamaApp.this, CInputHamaApp.class);
startActivity(i2);
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
// do nothing – it will close on its own
}
});
return builder.create();
}//createDialogSend2
i put createDialogSend2();
in this onPostExecute code
else {
tvStatus.setText("Sending Data : Finished");
CUtilities.showAlert(CInputHamaApp.this, "Data Terkirim");
createDialogSend2();
// Closing dashboard screen
}
but the result is when the status is finished the dialog show alert only, and createDialogSend2();
not running.
how to show createDialogSend2()
when text send Data is finished
BR
Alex
Upvotes: 0
Views: 2054
Reputation: 1417
this works for me, in OnPostExecute Method.
I add Activity object as propretie in my AsyncTask Class which I instantiate in the constructor of that AsyncTack so that I can call that activity and perform runOnUiThread in onpostexe...
AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
builder.setTitle("Connection ?");
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage("Test \n ");
builder.setPositiveButton("Ok",null);
final AlertDialog alert = builder.create();
Activity.runOnUiThread(new java.lang.Runnable(){
public void run(){
//show AlertDialog
alert.show();
}
});
Upvotes: 0
Reputation: 3261
Try this,
AlertDialog alert = builder.create();
alert.show();
Add this in your createDialogSend2()
Upvotes: 0
Reputation: 2541
Your function doesn't show()
the dialog. you need something like...
AlertDialog dlg = createDialogSend2();
dlg.show();
Upvotes: 3