1

Due to Background Service Limitations in Oreo, I put up my Service (used in Nougat, API 25) to send data to Wear (API 23) using Jobscheduler (as recommended replacement). There I am using an AsyncTask to send data to my wearable.

    PutDataMapRequest putDataMapReq = PutDataMapRequest.create("/nextAppt");
    putDataMapReq.getDataMap().putLong("appt", nextAppt);

    PutDataRequest putDataReq = putDataMapReq.asPutDataRequest();
    putDataReq.setUrgent();
    PendingResult<DataApi.DataItemResult> pendingResult =
            Wearable.DataApi.putDataItem(mGoogleApiClient, putDataReq);

This works fine as a regular Service (pre-Oreo), but not from a Jobservice (no matter if my MainActivity is in foreground or not). There is also no error message, etc. Just that nothing arrives at my Wear-device.

As I want to avoid using a foreground Service I am out of ideas right now, how to accomplish this or why exactly it does not work...

tomseitz
  • 503
  • 2
  • 4
  • 14
  • Any particular reason you're using an `AsyncTask` to do this? I don't think it's necessary with `putDataItem`, and while I can't see why it'd be causing the problem, it wouldn't much surprise me either. – Sterling Sep 28 '17 at 23:30
  • You are right in so far, as it is not necessary (pre-Oreo) to use `AsyncTask`. It was one of my attempts to make sure, the `putDataItem` will not be killed by the system. Nevertheless it does not work on Oreo any more. – tomseitz Sep 29 '17 at 07:24

0 Answers0