简体   繁体   中英

onRunTask never gets called

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?

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM