我已经从下面的链接中实现了代码来检查应用程序的空闲时间 如何打算在 android 上的另一个页面/从空闲时间弹出消息?
而是使用线程我使用了异步任务......现在我的问题一旦达到空闲时间......我想向用户应用程序显示对话框是从登录活动结束重新登录......我如何从异步任务 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)
}
}