我已經實現代碼的形式下面鏈接查看應用程序 How to intent to another page on android/pop up a message from idle time?如何在android中顯示asyntask的nonUI活動對話框?
的空閒時間,而不是使用線程我用asyntask ......現在我的問題,一旦達到空閒time..i要顯示對話框用戶應用程序需要重新登錄結束從登錄活動.. 我怎樣才能調用對話從的AsyncTask onpostExcute
public class session extends AsyncTask<Void,Void,Void> {
private static final String TAG=session.class.getName();
private long lastUsed;
private long period;
private boolean stop;
Context context;
final Dialog dialog = new Dialog(context);
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
//here i do the process.......
}
@Override
protected void onPostExecute(Void x){
//stuff to be done after task executes(done on UI thread)
// For Dialog Button**********************************
dialog.setContentView(R.layout.dialog);
dialog.setTitle("Result");
final TextView dialogtxt = (TextView) dialog
.findViewById(R.id.textView1);
final Button closeButton = (Button) dialog
.findViewById(R.id.button1);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
dialogtxt.setText("session time out");
dialog.show();
// ****************************************************
}
@Override
protected void onPreExecute(){
//stuff to be done after task executes(done on UI thread)
}
}
你的問題不清楚。放一些示例代碼 – waqaslam 2012-07-31 09:36:28
您可以在'onPostExecude()'中與UI線程進行交互。我沒有看到你的問題。 – nkr 2012-07-31 09:37:19
我更新code.please回覆如何顯示對話框 – vijay 2012-07-31 10:31:16