<i id='fkssD'><tr id='fkssD'><dt id='fkssD'><q id='fkssD'><span id='fkssD'><b id='fkssD'><form id='fkssD'><ins id='fkssD'></ins><ul id='fkssD'></ul><sub id='fkssD'></sub></form><legend id='fkssD'></legend><bdo id='fkssD'><pre id='fkssD'><center id='fkssD'></center></pre></bdo></b><th id='fkssD'></th></span></q></dt></tr></i><div id='fkssD'><tfoot id='fkssD'></tfoot><dl id='fkssD'><fieldset id='fkssD'></fieldset></dl></div>
<legend id='fkssD'><style id='fkssD'><dir id='fkssD'><q id='fkssD'></q></dir></style></legend>
  • <tfoot id='fkssD'></tfoot>
      <bdo id='fkssD'></bdo><ul id='fkssD'></ul>
  • <small id='fkssD'></small><noframes id='fkssD'>

        Android:首次运行弹出对话框

        时间:2023-08-31
            <tbody id='ySQuK'></tbody>
          <tfoot id='ySQuK'></tfoot>
        • <small id='ySQuK'></small><noframes id='ySQuK'>

          <i id='ySQuK'><tr id='ySQuK'><dt id='ySQuK'><q id='ySQuK'><span id='ySQuK'><b id='ySQuK'><form id='ySQuK'><ins id='ySQuK'></ins><ul id='ySQuK'></ul><sub id='ySQuK'></sub></form><legend id='ySQuK'></legend><bdo id='ySQuK'><pre id='ySQuK'><center id='ySQuK'></center></pre></bdo></b><th id='ySQuK'></th></span></q></dt></tr></i><div id='ySQuK'><tfoot id='ySQuK'></tfoot><dl id='ySQuK'><fieldset id='ySQuK'></fieldset></dl></div>

            <bdo id='ySQuK'></bdo><ul id='ySQuK'></ul>

                  <legend id='ySQuK'><style id='ySQuK'><dir id='ySQuK'><q id='ySQuK'></q></dir></style></legend>
                1. 本文介绍了Android:首次运行弹出对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试制作一个仅在应用首次运行后显示的弹出对话框,它会提醒用户应用中的新更改.所以我有一个这样的对话框弹出:

                  I am trying to make a popup dialog that only shows after the app's first run that will alert users of the new changes in the app. So I have a dialog popup like this:

                  new AlertDialog.Builder(this).setTitle("First Run").setMessage("This only pops up once").setNeutralButton("OK", null).show();
                  

                  一旦他们关闭它,它就不会回来,直到下一次更新或他们重新安装应用程序.

                  Once they dismiss it, it won't come back until the next update or they reinstall the app.

                  如何将上面的对话框代码设置为只运行一次?

                  How can I set the dialog code above to run only once?

                  推荐答案

                  使用 SharedPreferences 来存储 isFirstRun 值,并根据该值签入您的启动活动.

                  Use SharedPreferences to store the isFirstRun value, and check in your launching activity against that value.

                  如果设置了值,则不需要显示对话框.否则,显示对话框并将 isFirstRun 标志保存在 SharedPreferences 中.

                  If the value is set, then no need to display the dialog. If else, display the dialog and save the isFirstRun flag in SharedPreferences.

                  例子:

                  public void checkFirstRun() {
                      boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true);
                      if (isFirstRun){
                          // Place your dialog code here to display the dialog
                  
                          getSharedPreferences("PREFERENCE", MODE_PRIVATE)
                            .edit()
                            .putBoolean("isFirstRun", false)
                            .apply();
                      }
                  }
                  

                  这篇关于Android:首次运行弹出对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:第二次在对话框中膨胀片段时出错 下一篇:定时无模式对话

                  相关文章

                  最新文章

                  <legend id='N8XFQ'><style id='N8XFQ'><dir id='N8XFQ'><q id='N8XFQ'></q></dir></style></legend>
                  <i id='N8XFQ'><tr id='N8XFQ'><dt id='N8XFQ'><q id='N8XFQ'><span id='N8XFQ'><b id='N8XFQ'><form id='N8XFQ'><ins id='N8XFQ'></ins><ul id='N8XFQ'></ul><sub id='N8XFQ'></sub></form><legend id='N8XFQ'></legend><bdo id='N8XFQ'><pre id='N8XFQ'><center id='N8XFQ'></center></pre></bdo></b><th id='N8XFQ'></th></span></q></dt></tr></i><div id='N8XFQ'><tfoot id='N8XFQ'></tfoot><dl id='N8XFQ'><fieldset id='N8XFQ'></fieldset></dl></div>

                  <small id='N8XFQ'></small><noframes id='N8XFQ'>

                    <tfoot id='N8XFQ'></tfoot>

                      • <bdo id='N8XFQ'></bdo><ul id='N8XFQ'></ul>