I am making a kind of KYC single use App for a very specific business. It will store data including for each user :
And it has to work offline.
When the Android device will be connected, and it can be 1 or 2 days later, the App will have to send out all the data previously stored in the pipe.
You can implement it using GCMNetworkManager
. This API provides both period and one time tasks to send data in background. You can schedule network task depending on some conditions like when connected to WiFi (your case), when charging.
So following your case, you can write one-off
task to achieve it:
OneoffTask task = new OneoffTask.Builder()
.setService(MyTaskService.class)
.setTag(TASK_TAG_WIFI)
.setExecutionWindow(0L, 3600L)
.setRequiredNetwork(Task.NETWORK_STATE_UNMETERED)
.build();
mGcmNetworkManager.schedule(task);
Now MyTaskService
can be implemented like this:
public class MyTaskService extends GcmTaskService {
@Override
public int onRunTask(TaskParams taskParams) {
//some network oriented synchronous tasks.
return GcmNetworkManager.RESULT_SUCCESS;
}
Will I have to run the app in order to send the data when I will have a WIFI connection?
No