use of android.app.NotificationManager in project android_frameworks_base by ParanoidAndroid.
the class TestAlertActivity method onPause.
@Override
public void onPause() {
super.onPause();
Log.d("StatusBarTest", "onPause: Canceling notification id=" + mId);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.cancel(mId);
finish();
}
use of android.app.NotificationManager in project GT by Tencent.
the class NotificationHelper method notify.
// 1.实例化Notification类
// 2.设置Notification对象的icon,通知文字,声音
// 3.实例化PendingIntent类,作为控制点击通知后显示内容的对象
// 4.加载PendingIntent对象到Notification对象(设置 打开通知抽屉后的 标题/内容)
// 5.获得 NotificationManager对象
// 6.使用NotificationManager对象显示通知
/**
* 发布通知
*
* @param c
* 上下文
* @param notifyId
* 通知标识id
* @param n
* 通知对象
*/
public static void notify(Context c, int notifyId, Notification n) {
final NotificationManager nm = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE);
// 显示通知
nm.notify(notifyId, n);
}
use of android.app.NotificationManager in project SeriesGuide by UweTrottmann.
the class TraktCredentials method setCredentialsInvalid.
/**
* Removes the current trakt access token (but not the username), so {@link #hasCredentials()}
* will return {@code false}, and shows a notification asking the user to re-connect.
*/
public synchronized void setCredentialsInvalid() {
if (!mHasCredentials) {
// already invalidated credentials
return;
}
removeAccessToken();
Timber.e("trakt credentials invalid, removed access token");
NotificationCompat.Builder nb = new NotificationCompat.Builder(mContext);
nb.setSmallIcon(R.drawable.ic_notification);
nb.setContentTitle(mContext.getString(R.string.trakt_reconnect));
nb.setContentText(mContext.getString(R.string.trakt_reconnect_details));
nb.setTicker(mContext.getString(R.string.trakt_reconnect_details));
PendingIntent intent = TaskStackBuilder.create(mContext).addNextIntent(new Intent(mContext, ShowsActivity.class)).addNextIntent(new Intent(mContext, ConnectTraktActivity.class)).getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
nb.setContentIntent(intent);
nb.setAutoCancel(true);
nb.setColor(ContextCompat.getColor(mContext, R.color.accent_primary));
nb.setPriority(NotificationCompat.PRIORITY_HIGH);
nb.setCategory(NotificationCompat.CATEGORY_ERROR);
NotificationManager nm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(SgApp.NOTIFICATION_TRAKT_AUTH_ID, nb.build());
}
use of android.app.NotificationManager in project Fairphone by Kwamecorp.
the class UpdaterService method setNotification.
private void setNotification() {
Context context = getApplicationContext();
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.fairphone_updater_tray_icon_small).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.fairphone_updater_tray_icon)).setContentTitle(context.getResources().getString(R.string.app_name)).setContentText(getResources().getString(R.string.fairphoneUpdateMessage));
Intent resultIntent = new Intent(context, FairphoneUpdater.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(FairphoneUpdater.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
Notification notificationWhileRunnig = builder.build();
// Add notification
manager.notify(0, notificationWhileRunnig);
//to update the activity
Intent updateIntent = new Intent(FairphoneUpdater.FAIRPHONE_UPDATER_NEW_VERSION_RECEIVED);
sendBroadcast(updateIntent);
}
use of android.app.NotificationManager in project XPrivacy by M66B.
the class UpdateService method notifyProgress.
private static void notifyProgress(Context context, int id, String format, int percentage) {
String message = String.format(format, String.format("%d %%", percentage));
Util.log(null, Log.WARN, message);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentTitle(context.getString(R.string.app_name));
builder.setContentText(message);
builder.setWhen(System.currentTimeMillis());
builder.setAutoCancel(percentage == 100);
builder.setOngoing(percentage < 100);
Notification notification = builder.build();
notificationManager.notify(id, notification);
}
Aggregations