Search in sources :

Example 51 with NotificationManager

use of android.app.NotificationManager in project android_frameworks_base by ResurrectionRemix.

the class BaseStatusBar method showNavigationNotification.

private void showNavigationNotification(boolean show) {
    NotificationManager noMan = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    if (show && !mIsNavNotificationShowing) {
        Intent intent = new Intent(ACTION_ENABLE_NAVIGATION_KEY);
        intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.setPackage(mContext.getPackageName());
        final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
        final Notification notification = new Notification.Builder(mContext).setContentTitle(mContext.getResources().getString(R.string.no_navigation_warning_title)).setContentText(mContext.getResources().getString(R.string.no_navigation_warning_text)).setSmallIcon(R.drawable.no_navigation_warning_icon).setOngoing(true).setAutoCancel(false).setVisibility(Notification.VISIBILITY_PUBLIC).setContentIntent(pendingIntent).build();
        mIsNavNotificationShowing = true;
        noMan.notify(R.string.no_navigation_warning_title, notification);
    } else if (mIsNavNotificationShowing) {
        mIsNavNotificationShowing = false;
        noMan.cancel(R.string.no_navigation_warning_title);
    }
}
Also used : NotificationManager(android.app.NotificationManager) TaskStackBuilder(android.app.TaskStackBuilder) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 52 with NotificationManager

use of android.app.NotificationManager in project android_frameworks_base by ResurrectionRemix.

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 53 with NotificationManager

use of android.app.NotificationManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SimSelectNotification method createNotification.

private void createNotification(Context context) {
    final Resources resources = context.getResources();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp).setColor(context.getColor(R.color.sim_noitification)).setContentTitle(resources.getString(R.string.sim_notification_title)).setContentText(resources.getString(R.string.sim_notification_summary));
    Intent resultIntent = new Intent(context, SimSettingsActivity.class);
    resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setContentIntent(resultPendingIntent);
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, builder.build());
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Resources(android.content.res.Resources) PendingIntent(android.app.PendingIntent)

Example 54 with NotificationManager

use of android.app.NotificationManager in project RSAndroidApp by RailwayStations.

the class MyFirebaseMessagingService method onMessageReceived.

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // Handle data payload of FCM messages.
    Log.d(TAG, "onMessageReceived");
    Log.d(TAG, "FCM Message Id: " + remoteMessage.getMessageId());
    Log.d(TAG, "FCM Notification Message: " + remoteMessage.getNotification());
    Log.d(TAG, "FCM Data Message: " + remoteMessage.getData());
    String title = remoteMessage.getNotification().getTitle();
    String message = remoteMessage.getNotification().getBody();
    String click_action = remoteMessage.getNotification().getClickAction();
    Intent intent = new Intent(click_action);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder.setContentTitle(title);
    notificationBuilder.setContentText(message);
    notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);
    notificationBuilder.setAutoCancel(true);
    notificationBuilder.setGroup(KEY_NOTIFICATION_GROUP);
    notificationBuilder.setGroupSummary(true);
    notificationBuilder.setContentIntent(pendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 55 with NotificationManager

use of android.app.NotificationManager in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mgr.cancel(PackageReceiver.NOTIFY_ID);
    if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
        getFragmentManager().beginTransaction().add(android.R.id.content, new SettingsFragment()).commit();
    }
}
Also used : 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