forked from Etar-Group/Etar-Calendar
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Get notified when a new event has come.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/com/android/calendar/alerts/ProviderChangedReceiverAsJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.android.calendar.alerts; | ||
|
||
import android.annotation.TargetApi; | ||
import android.app.job.JobInfo; | ||
import android.app.job.JobParameters; | ||
import android.app.job.JobScheduler; | ||
import android.app.job.JobService; | ||
import android.appwidget.AppWidgetManager; | ||
import android.content.ComponentName; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Build; | ||
import android.os.Handler; | ||
import android.provider.CalendarContract; | ||
import android.widget.Toast; | ||
|
||
import com.android.calendar.widget.CalendarAppWidgetProvider; | ||
import com.android.calendar.widget.CalendarAppWidgetService; | ||
|
||
@TargetApi(Build.VERSION_CODES.N) | ||
public class ProviderChangedReceiverAsJob extends JobService { | ||
private static final int mJobId = 1005; //Job Id | ||
final Handler mHandler = new Handler(); //Just to display Toasts | ||
|
||
public static void schedule(Context oContext) { | ||
ComponentName oComponentName = new ComponentName(oContext, ProviderChangedReceiverAsJob.class); | ||
JobInfo.Builder oJobInfoBuilder = new JobInfo.Builder(mJobId, oComponentName); | ||
final Uri CALENDAR_URI = Uri.parse("content://" + CalendarContract.AUTHORITY + "/"); | ||
oJobInfoBuilder.addTriggerContentUri(new JobInfo.TriggerContentUri(CalendarContract.CONTENT_URI, JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS)); | ||
oJobInfoBuilder.addTriggerContentUri(new JobInfo.TriggerContentUri(CALENDAR_URI, 0)); | ||
JobScheduler jobScheduler = (JobScheduler) oContext.getSystemService(Context.JOB_SCHEDULER_SERVICE); | ||
jobScheduler.schedule(oJobInfoBuilder.build()); | ||
} | ||
|
||
|
||
@Override | ||
public boolean onStartJob(JobParameters params) { | ||
//Toast.makeText(getApplicationContext(), "Update The widget!", Toast.LENGTH_SHORT).show(); | ||
|
||
//TODO: Here should be the update of the widgets. | ||
|
||
|
||
schedule(this); //Reschedule to receive future changes | ||
return (false); | ||
} | ||
|
||
|
||
@Override | ||
synchronized public boolean onStopJob(JobParameters params) { | ||
return (false); | ||
} | ||
|
||
} |