Android and android

Source: Internet
Author: User

Android and android
Android Anti-Virus

Today's cleanup software, such as 360, has a one-click cleanup function. It will kill the programs running in the background one by one. After the program dies, it does not take a normal life cycle, for example, calling the ondestory method. How can we keep the program running in the background without being killed by 360?

After testing several methods, I finally found a method. Android has a synchronization ToolSync AdapterYou can run the task periodically after registration. In this way, even if your process is killed by him, it will automatically restart within a certain period of time. Android develop website has his introduction: Run the Sync Adapter Periodically

You can download the official example to see how he declares the registration. The addPeriodicSync method is the method for adding periodic operations.

1 android.content.ContentResolver.addPeriodicSync(Account account, String authority, Bundle extras, long pollFrequency)

PollFrequency is the cycle time, in seconds.

However, in the actual test process, it is found that his cycle is not necessarily the time you write, sometimes fast and sometimes slow, because

Although these sync are scheduled at the specified frequency, it may take longer for it to actually be started if other syncs are ahead of it in the sync operation queue. this means that the actual start time may drift.

Your synchronizers will be affected by others' synchronizers.


How does Android prevent Service from being killed? What should I do if Service is killed?

Set the onStartCommand return value of Service to START_STICKY.
Bytes -----------------------------------------------------------------------------------------------------
Answers from the android team
Welcome to the android excellent team!

[10] A self-written android widget is sometimes killed by the system. How can this problem be solved?

How do you determine that the system has killed you?
There are many reasons why the widget does not respond when you click it. You still need to check the log to find the cause.

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.