アプリケーションのアイドル時間を確認するために、以下のリンクからコードを実装し ました。Androidの別のページにインテントする方法/アイドル時間からメッセージをポップアップする方法は?
代わりにスレッドを使用してasyntaskを使用しました...アイドル時間に達したら問題が発生します。ユーザーアプリケーションにダイアログを表示したいのは、ログインアクティビティからの再ログインを終了することです。非同期タスク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)
}
}