<legend id='B2f9K'><style id='B2f9K'><dir id='B2f9K'><q id='B2f9K'></q></dir></style></legend>
  1. <small id='B2f9K'></small><noframes id='B2f9K'>

    <tfoot id='B2f9K'></tfoot>
      <bdo id='B2f9K'></bdo><ul id='B2f9K'></ul>
      <i id='B2f9K'><tr id='B2f9K'><dt id='B2f9K'><q id='B2f9K'><span id='B2f9K'><b id='B2f9K'><form id='B2f9K'><ins id='B2f9K'></ins><ul id='B2f9K'></ul><sub id='B2f9K'></sub></form><legend id='B2f9K'></legend><bdo id='B2f9K'><pre id='B2f9K'><center id='B2f9K'></center></pre></bdo></b><th id='B2f9K'></th></span></q></dt></tr></i><div id='B2f9K'><tfoot id='B2f9K'></tfoot><dl id='B2f9K'><fieldset id='B2f9K'></fieldset></dl></div>
    1. AlertDialog.show 在服务中被忽略

      时间:2023-08-30

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

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

              <tfoot id='zSLC6'></tfoot>
              • <bdo id='zSLC6'></bdo><ul id='zSLC6'></ul>

              • 本文介绍了AlertDialog.show 在服务中被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有一个运行后台线程的服务.我想做的是显示从我的后台线程启动的 AlertDialog.我知道这不是通知用户的推荐方式,并且它中断工作流程(因为它们可以随时在任何应用程序中弹出时间),但它适合我的用例.

                I have a service running a background thread. What I'd like to do is to show an AlertDialog initiated from my background thread. I know that this is not the recommended way of notifying the user and that it interrupts the workflow (as they can pop-up in any application at any time) but it's a suitable way for my use case.

                有一个处理程序注册到后台线程并显示一个带有处理程序的 Toast 通知工作正常.但是切换后到 AlertDialog 什么也没有发生.我的 showDialog 逻辑是默默无视.没有对话窗口出现,没有日志条目.有点奇怪,因为我希望至少有一个日志条目说我正在做有什么不对或什么的.

                There is a handler registered with the background thread and showing a Toast notification withing the handler works fine. But after switching to an AlertDialog nothing happens anymore. My showDialog logic is silently ignored. No Dialog window appears, no log entry. It's a bit strange as I'd expect at least a log entry saying that I'm doing something wrong or whatever.

                显示从服务后台线程?有些人似乎推荐一个Dialog主题Activity 以获得类似的行为.

                Are there any limitations for showing an AlertDialog initiated from a service background thread? Some people seem to recommend a Dialog themed Activity to get a similar behavior.

                非常感谢任何澄清或帮助使其工作!

                Any clarification or help making it work is greatly appreciated!

                伊夫

                推荐答案

                可以从后台线程打开对话框.诀窍是启动一个看起来像对话框的活动:

                It is possible to open a dialog from a background thread. The trick is to start an activity which looks like a dialog:

                <activity android:label="@string/app_name" android:name="YourDialog" android:theme="@android:style/Theme.Dialog"/>
                

                然后,开始您的活动:

                Intent dialog = new Intent(this, YourDialog.class);
                dialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(dialog);
                

                请注意,这是异步的,不会阻塞.如果要处理结果,则必须使用 startService() 并传递自定义活动来指示结果.

                Note that this is asyncrhonous and doesn't block. If you want to process the result, you'll have to use startService() and pass a custom activity to indicate a result.

                伊曼纽尔

                这篇关于AlertDialog.show 在服务中被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 onDismiss() 从 DialogFragment 获取信息 下一篇:使用 AlertDialog 的模态对话框功能

                相关文章

                最新文章

                  • <bdo id='33QzC'></bdo><ul id='33QzC'></ul>
                  1. <small id='33QzC'></small><noframes id='33QzC'>

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