googlearchive/firebase-jobdispatcher-android

How do you get notified of new pictures (every time)

recheej opened this issue · 1 comments

The job only gets called one time. What am I doing wrong?

    private void scheduleMediaTriggerJob (Uri contentUri) {
        Log.i(this.getClass().getCanonicalName(), "scheduling media trigger job");

        List<ObservedUri> observedUris = new ArrayList<>(1);
        observedUris.add(new ObservedUri(contentUri, ObservedUri.Flags.FLAG_NOTIFY_FOR_DESCENDANTS));

        Bundle extras = new Bundle();
        extras.putString(UploaderScanJobService.CONTENT_URI, contentUri.toString());

        Job scanMediaJob = mJobDispatcher.newJobBuilder()
                .setTrigger(Trigger.contentUriTrigger(observedUris))
                .setTag("media-scan-job-" + contentUri.hashCode())
                .setService(UploaderScanJobService.class)
                .setExtras(extras)
                .build();

        mJobDispatcher.mustSchedule(scanMediaJob);
    }

I call this in my Application class' onCreate:
scheduleMediaTriggerJob(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

My job service:

package com.yahoo.mobile.client.android.flickr.upload;

import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.util.Log;

import com.firebase.jobdispatcher.JobParameters;
import com.firebase.jobdispatcher.JobService;

import java.io.File;

public class UploaderScanJobService extends JobService {

    public static final String TAG = "upload job service";
    public static final int SCAN_FINISHED = 0;
    public static final String CONTENT_URI = "content_uri";

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "creating uploader scan job");
    }

    @Override
    public boolean onStartJob(final JobParameters job) {

        Log.i(TAG, "starting upload scan");

        return false;
    }

    @Override
    public boolean onStopJob(JobParameters job) {
        Log.i(TAG, "on stop job uploader scan service");

        return false;
    }
}

Manifest:

    <service
        android:exported="false"
        android:name=".upload.UploaderScanJobService">
        <intent-filter>
            <action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE"/>
        </intent-filter>
    </service>

In April 2019 we announced that Firebase Job Dispatcher would be deprecated today, April 7th 2020. For this reason we are going to close all open issues and archive the repository. We will also stop supporting FJD for new app installations (such as those targeting sdk versions greater than Android Q). Existing apps that rely on FJD should continue to function as usual.

While we will no longer work on FJD, we encourage you to migrate to Work Manager which is a superior tool and fully supported by the Android team.

Thank you for taking the time to try the library and provide this feedback. We sincerely appreciate your effort and we apologize for not addressing it in time.