当互联网连接可用时,我使用此代码段进行一些服务:
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);
清单:
<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>
它在24岁以下的api上工作但不在24及以上,我怎样才能使它在这个api目标中工作?