use of android.app.NotificationManager in project android_frameworks_base by DirtyUnicorns.
the class NekoService method registerJob.
public static void registerJob(Context context, long intervalMinutes) {
JobScheduler jss = context.getSystemService(JobScheduler.class);
jss.cancel(JOB_ID);
long interval = intervalMinutes * MINUTES;
long jitter = (long) (INTERVAL_JITTER_FRAC * interval);
interval += (long) (Math.random() * (2 * jitter)) - jitter;
final JobInfo jobInfo = new JobInfo.Builder(JOB_ID, new ComponentName(context, NekoService.class)).setPeriodic(interval, INTERVAL_FLEX).build();
Log.v(TAG, "A cat will visit in " + interval + "ms: " + String.valueOf(jobInfo));
jss.schedule(jobInfo);
if (NekoLand.DEBUG_NOTIFICATIONS) {
NotificationManager noman = context.getSystemService(NotificationManager.class);
noman.notify(500, new Notification.Builder(context).setSmallIcon(R.drawable.stat_icon).setContentTitle(String.format("Job scheduled in %d min", (interval / MINUTES))).setContentText(String.valueOf(jobInfo)).setPriority(Notification.PRIORITY_MIN).setCategory(Notification.CATEGORY_SERVICE).setShowWhen(true).build());
}
}
use of android.app.NotificationManager in project android_frameworks_base by DirtyUnicorns.
the class MainActivity method sendNotification.
private void sendNotification(int count) {
Notification.Builder builder = new Notification.Builder(this).setContentTitle(String.format("%s OSU available", count)).setContentText("Choose one to connect").setSmallIcon(android.R.drawable.ic_dialog_info).setAutoCancel(false);
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
use of android.app.NotificationManager in project android_frameworks_base by DirtyUnicorns.
the class MainActivity method cancelNotification.
private void cancelNotification() {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);
}
use of android.app.NotificationManager in project android_frameworks_base by DirtyUnicorns.
the class Tethering method clearTetheredNotification.
private void clearTetheredNotification() {
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null && mLastNotificationId != 0) {
notificationManager.cancelAsUser(null, mLastNotificationId, UserHandle.ALL);
mLastNotificationId = 0;
}
}
use of android.app.NotificationManager in project android_frameworks_base by DirtyUnicorns.
the class DeviceStorageMonitorService method cancelNotification.
/**
* Cancels low storage notification and sends OK intent.
*/
private void cancelNotification() {
final Context context = getContext();
if (localLOGV)
Slog.i(TAG, "Canceling low memory notification");
NotificationManager mNotificationMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
//cancel notification since memory has been freed
mNotificationMgr.cancelAsUser(null, LOW_MEMORY_NOTIFICATION_ID, UserHandle.ALL);
context.removeStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
context.sendBroadcastAsUser(mStorageOkIntent, UserHandle.ALL);
}
Aggregations