Search in sources :

Example 76 with NotificationManager

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());
    }
}
Also used : JobScheduler(android.app.job.JobScheduler) NotificationManager(android.app.NotificationManager) JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName)

Example 77 with NotificationManager

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());
}
Also used : NotificationManager(android.app.NotificationManager) TaskStackBuilder(android.app.TaskStackBuilder) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.app.TaskStackBuilder) Notification(android.app.Notification)

Example 78 with NotificationManager

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);
}
Also used : NotificationManager(android.app.NotificationManager)

Example 79 with NotificationManager

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;
    }
}
Also used : NotificationManager(android.app.NotificationManager)

Example 80 with NotificationManager

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);
}
Also used : Context(android.content.Context) NotificationManager(android.app.NotificationManager)

Aggregations

NotificationManager (android.app.NotificationManager)930 Intent (android.content.Intent)400 PendingIntent (android.app.PendingIntent)397 Notification (android.app.Notification)276 NotificationCompat (android.support.v4.app.NotificationCompat)267 NotificationChannel (android.app.NotificationChannel)129 Uri (android.net.Uri)62 Context (android.content.Context)59 SharedPreferences (android.content.SharedPreferences)41 Bitmap (android.graphics.Bitmap)41 Resources (android.content.res.Resources)39 Bundle (android.os.Bundle)36 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)35 SuppressLint (android.annotation.SuppressLint)27 TargetApi (android.annotation.TargetApi)26 TaskStackBuilder (android.app.TaskStackBuilder)25 StatusBarNotification (android.service.notification.StatusBarNotification)24 IOException (java.io.IOException)22 File (java.io.File)20 IntentFilter (android.content.IntentFilter)18