<tfoot id='Ooky3'></tfoot>

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

    1. <legend id='Ooky3'><style id='Ooky3'><dir id='Ooky3'><q id='Ooky3'></q></dir></style></legend>

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

        Android:intentservice,如何中止或跳过handleintent队列中的任务

        时间:2024-04-14

      2. <small id='nYv0L'></small><noframes id='nYv0L'>

      3. <legend id='nYv0L'><style id='nYv0L'><dir id='nYv0L'><q id='nYv0L'></q></dir></style></legend>
      4. <tfoot id='nYv0L'></tfoot>

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

              <tbody id='nYv0L'></tbody>

                • <bdo id='nYv0L'></bdo><ul id='nYv0L'></ul>
                  本文介绍了Android:intentservice,如何中止或跳过handleintent队列中的任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个调用意图服务(DownloadService")的活动(ApplicationActivity")

                  i have an activity ("ApplicationActivity") that call an intent service ("DownloadService")

                  intentService 在后台从互联网下载文件,但我希望能够中止特定的下载............

                  The intentService download files from internet in background, but i want to be able to abort a specific download.........

                  假设我将 5 个文件放入队列中:文件 1、2、3、4、5

                  So let's say that i put 5 files in queue: file 1,2,3,4,5

                  intent 服务开始下载数字 1,然后是第二个,依此类推....1)有没有办法在方法句柄事件中告诉意图服务中止你正在做的事情(在这种情况下是下载文件1)并开始下载下一个?

                  The intent service start downloading the number 1, then the second and so on.... 1) Is there a way to say to the intent service abort what you are doing at the moment in the method handle event (in this case downloading file 1) and start downloading the next one?

                  2)是否可以从队列中删除元素,例如在下载文件1时,将文件4从队列中删除,以便在数字3之后直接进入5?

                  2)Is it possible to remove element from the queue, so for example while is downloading file 1, remove the file 4 from the queue so that after the number 3 it goes straight to the 5?

                  简而言之,我需要一种与队列通信的方法来执行这两个简单的操作,但我在互联网上没有发现任何有用的东西:(

                  Shortly, i need a way to comunicate with the queue to perform these 2 simple operations, but i didn't find nothing usefull on internet :(

                  Tnx

                  推荐答案

                  我创建自己的 MyIntentService 类,复制非常短的原始类并为我自己的目的修改方法........特别是出队在我的情况下,您可以使用 ServiceHandler 方法的元素
                  mServiceHandler.removeMessages(appId);
                  删除消息队列中带有特定代码what"的任何待处理消息帖子,这意味着您必须标记添加到队列中的每条消息,并在每条消息的what"字段内添加一个标识符........例如

                  I create my own MyIntentService class copying the original one that is pretty short and modifying methods for my own purpose........in particular to dequeue an element you can use methods of ServiceHandler in my case
                  mServiceHandler.removeMessages(appId);
                  that Remove any pending posts of messages with a certain code 'what' that are in the message queue, this means that you have to label each message you add in the queue adding an identifier inside the "what" field of each message.....for example

                  public void onStart(Intent intent, int startId) 
                  {
                      super.onStart(intent, startId);
                      Message msg = mServiceHandler.obtainMessage();
                      msg.arg1 = startId;
                      msg.obj = intent;
                      msg.what = intent.getIntExtra("appId", 0); \parameters that come from the outside
                  

                  这篇关于Android:intentservice,如何中止或跳过handleintent队列中的任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何停止/取消/暂停/恢复 GCD 队列上的任务 下一篇:为什么 dispatch_queue_create 在 Swift 中会给出 EXC_BAD_ACCESS 错误?

                  相关文章

                    <tfoot id='L4hvH'></tfoot>

                  1. <legend id='L4hvH'><style id='L4hvH'><dir id='L4hvH'><q id='L4hvH'></q></dir></style></legend>

                  2. <small id='L4hvH'></small><noframes id='L4hvH'>

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

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