android - File Cleaning Service -


As a requirement in the Android OS phone, I am developing an app that will clean up a specific folder in a particular interval of time.

Speak up every 30 minutes.

I can run a service and clean the folder every 30 minutes. I have some questions on this,

1. The server is onstart commm, which will be executed upon the service start, can I call the function here, which is a 30-minute handler running? Example

  public int onStartCommand (intention intent, int-flags, int startId) {cleanUpData (); Return START_REDELIVER_INTENT; } Public Zero cleanUpData () {handler handler = new handler (); Handler. PostDelayed (New Runnabel) {@Override public void run ()} // Function again cleanedData ();}}, "30 minutes"); }  

This code repeats CleanUpData every 30 minutes. a. is this correct? B. Will this affect performance? C. Should I use a different thread mentioned in several tutorials? D. Should I Use All After Service? Or is there any other way?

  1. Alarm Manager provides Scheduled Repeats Alarms, but it does not work when the phone is in sleep mode I do not want to wake up the screen because it's the interaction of any human Not required. Can I ignore the alarm manager? Or alarmman has the functionality to run the code, even when the phone is in sleep mode and it is false to raise the phone?

Please suggest. thank you in advanced!

You should use a different thread to clear the folder. I will not suggest you to use handler in a service because it runs in the same process as the app, so a long-running operation can make it uncontrollable, instead it runs on its own thread, and the device's For a sleep problem a broadcast receiver starts to fire and receives custom wake lock in this broadcast receiver and then invites you to this service.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -