Ask questions about Android background tasks and services

Source: Internet
Author: User

============ Problem Description ============


Recently in an application, real-time detection of network signals, the log is the system automatically crawl, a service detection log to meet certain conditions, began to compress the archive, I use Asynctask to detect the network signal, the signal value through progress update to the foreground, after the application started, open a service to detect the log situation. Now the problem is that when the log reaches the start of a compression, will block the foreground signal updates, one is a service, a background task, 're told will not block the main thread, there is only one process to send messages to the mobile phone? I hope you have more advice ~-~

============ Solution 1============


Aidl Bai, very useful,,,

============ Solution 2============


Although Asynctask is a background task, it is not suitable for long-time tasks.

============ Solution 3============


The official documentation gives the description that Asynctask does not build a generic threading framework and cannot perform time-consuming operations up to a few seconds. Note that asynctask and a normal thread are not the same.

============ Solution 4============


Reference 4 Floor jeky198306 's reply:
Thank you for guidance, do you have a good way to deal with this? Got aidl. To install two applications, the user experience is not good


Quote: Referring to the reply of the 3 floor Lionfresh:

The official documentation gives the description that Asynctask does not build a generic threading framework and cannot perform time-consuming operations up to a few seconds. Note that asynctask and a normal thread are not the same.


You can also detect network signals in another service, and broadcast to notify the UI thread to update the interface.

============ Solution 5============


The service runs in the main thread, the service blocks the UI, and the Asytask Doinbackground is another thread.

============ Solution 6============


How do you get points?????????????????????

Ask questions about Android background tasks and services

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.