diff --git a/samples/ApiDemos/src/com/example/android/apis/content/JobIds.java b/samples/ApiDemos/src/com/example/android/apis/content/JobIds.java new file mode 100644 index 000000000..14547425c --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/content/JobIds.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2016, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.apis.content; + +/** + * Global constant job IDs used by the app. + */ +public final class JobIds { + static final int MEDIA_CONTENT_JOB = 1; + static final int PHOTOS_CONTENT_JOB = 2; +} diff --git a/samples/ApiDemos/src/com/example/android/apis/content/MediaContentJob.java b/samples/ApiDemos/src/com/example/android/apis/content/MediaContentJob.java index 16c81a38e..3b6e9e416 100644 --- a/samples/ApiDemos/src/com/example/android/apis/content/MediaContentJob.java +++ b/samples/ApiDemos/src/com/example/android/apis/content/MediaContentJob.java @@ -33,7 +33,7 @@ import com.example.android.apis.R; import java.util.List; /** - * Stub job to execute when there is a change to any media: content URI. + * Example stub job to monitor when there is a change to any media: content URI. */ public class MediaContentJob extends JobService { static final Uri MEDIA_URI = Uri.parse("content://" + MediaStore.AUTHORITY + "/"); @@ -50,7 +50,7 @@ public class MediaContentJob extends JobService { public static void scheduleJob(Context context) { JobScheduler js = context.getSystemService(JobScheduler.class); - JobInfo.Builder builder = new JobInfo.Builder(R.id.schedule_media_job, + JobInfo.Builder builder = new JobInfo.Builder(JobIds.MEDIA_CONTENT_JOB, new ComponentName(context, MediaContentJob.class)); builder.addTriggerContentUri(new JobInfo.TriggerContentUri(MEDIA_URI, JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS)); @@ -65,7 +65,7 @@ public class MediaContentJob extends JobService { return false; } for (int i=0; i