onRunTask never gets called

401 views Asked by At

Im using GcmTaskService for sending data in the background, In most cases it works well, altough lately i got one complaint from a client that data is not being sent out of the device. Ive brought the device and I notice that my GcmTaskService's onRunTask never being called on this specific device.

This is how i initiate the service :

GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(FarmWorkApplication.context);
        Class<FarmWorkSyncOutService> gcmTaskService = FarmWorkSyncOutService.class;
        String name = gcmTaskService.getName();
        gcmNetworkManager.cancelTask(name, gcmTaskService);
        OneoffTask task = new OneoffTask.Builder()
                .setService(gcmTaskService)
                .setTag(name)
                .setExecutionWindow(0L, maxDelay)
                .setRequiredNetwork(Task.NETWORK_STATE_CONNECTED)
                .build();
        gcmNetworkManager.schedule(task);

This is the service definition in the manifest :

<service android:name=".FarmWorkSyncOutService"
        android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
        </intent-filter>
    </service>

The device is connected to the internet by WIFI and is surfing the internet very well.

This line :

gcmNetworkManager.cancelTask(name, gcmTaskService);

is just to assure the service runs once, i also tried to remove it and it didnt help

I tried force stopping GooglePlayServices and remove its data, it didnt help what else can i do to debug this? any1 got any idea why this could happen?

1

There are 1 answers

0
Ofek Ron On BEST ANSWER

This was the Power Saving Mode's fault. once i disabled it the device started syncing out. wonder if that was smart of them to make Services never run in the background at all...