I'm developing an app that needs to find a file on device. This process runs for 5 minutes trying to find the file.
My app starts after a BroadcastReceiver
for boot_completed
. After file search a service starts.
Below is the code for finding the file in until 5 minutes. This process repeats every 1 minute.
boolean found = false;
int tam = 0;
While(!found)
{
found = find_file(); //call the method to find the file.
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
}
}, 60000);
tam++
if(tam==5){
break;
}
}
Questions:
- Is there a better way to do this ?
- Could the operating system kill my app to save memory, causing the service to never be executed?