GcmNetworkManager Not working with API 24 and above

234 Views Asked by At

I use this code snippet to do some service when internet connection is available :

OneoffTask oneoffTask = new OneoffTask.Builder()
            .setService(DbTransferService.class)
            .setTag("DB_TRANSFER")
            .setExecutionWindow(0L, 1L)
            .setUpdateCurrent(false)
            .setRequiresCharging(true)
            .setRequiredNetwork(Task.NETWORK_STATE_CONNECTED)
            .build();
            gcmNetworkManager.schedule(oneoffTask);

Manifest :

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

It works prefect on api under 24 but not in 24 and above , how could I make it work in this api target?

0

There are 0 best solutions below