Reputation: 83
I have this OneTimeWorkRequest that don't trigger my SendFeedbackMessageWorker. The work request should get triggered with the constraint ".setRequiredNetworkType(NetworkType.CONNECTED)", but whenever I try to send a message without network connected and then connect again, the class is never triggered.
Can anybody point out where this is broken?
private void handleFeedbackMessageFailure(Context context, FeedbackMessage message) {
Constraints constraints4 = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build();
Data myFeedbackMessage = new Data.Builder()
.putString("myFeedbackMessageId", message.getId())
.putString("myFeedbackMessage", message.getFeedbackMessage())
.putString("myFeedbackPerson", message.getFeedbackPersonName())
.putString("myFeedbackCreated", message.getCreated().toString())
.build();
OneTimeWorkRequest sendFeedbackWorker = new OneTimeWorkRequest.Builder(SendFeedbackMessageWorker.class)
.setInputData(myFeedbackMessage)
.setConstraints(constraints4)
.build();
WorkManager.getInstance(context).enqueue(
sendFeedbackWorker
);
Upvotes: 1
Views: 604
Reputation: 1523
Check the JS info as described here:
https://developer.android.com/topic/libraries/architecture/workmanager/how-to/debugging
Use: adb shell dumpsys jobscheduler
In the result - check what is unstatisfied in the Constraints section.
If it is Connectivity:
Check what Capabilities you expect(part of the logs in the job info) and compare them to the current active network Capabilities.
Also if not enough time is the problem - you will see it there in the constraints.
Upvotes: 2