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.