JAVA/android_studio
2024. 10. 23. 10:42
-
public class MainActivity extends Activity { static final int TIME_OUT = 5000; static final int MSG_DISMISS_DIALOG = 0; private AlertDialog mAlertDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); createDialog(); } private Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { switch (msg.what) { case MSG_DISMISS_DIALOG: if (mAlertDialog != null && mAlertDialog.isShowing()) { mAlertDialog.dismiss(); } break; default: break; } } }; private void createDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setPositiveButton("OK", null) .setNegativeButton("cacel", null); mAlertDialog = builder.create(); mAlertDialog.show(); // dismiss dialog in TIME_OUT ms mHandler.sendEmptyMessageDelayed(MSG_DISMISS_DIALOG, TIME_OUT); } } |
https://stackoverflow.com/questions/17628784/how-to-timeout-an-alertdialog-in-android
How to timeout an AlertDialog in Android?
How can i handle timeout in an alertdialog. It has the standard yes/no button but i want to call the no button code if the user doesn't press anything in 5 minutes. I've looked at the class in Andr...
stackoverflow.com
'JAVA > android_studio' 카테고리의 다른 글
Thread.sleep not crash app (1) | 2024.10.24 |
---|---|
자바 코드 실행시간 구하기 (2) | 2024.10.23 |
GPS - UBLOX NEO-6M PPS pulse length and frequency setting (0) | 2024.10.04 |
안전하지 않은 앱 차단됨 (0) | 2024.09.17 |
TedPermission (0) | 2024.09.17 |