Search in sources :

Example 91 with NotificationManager

use of android.app.NotificationManager in project Conversations by siacs.

the class ExportLogsService method export.

private void export() {
    List<Conversation> conversations = mDatabaseBackend.getConversations(Conversation.STATUS_AVAILABLE);
    conversations.addAll(mDatabaseBackend.getConversations(Conversation.STATUS_ARCHIVED));
    NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext());
    mBuilder.setContentTitle(getString(R.string.notification_export_logs_title)).setSmallIcon(R.drawable.ic_import_export_white_24dp).setProgress(conversations.size(), 0, false);
    startForeground(NOTIFICATION_ID, mBuilder.build());
    int progress = 0;
    for (Conversation conversation : conversations) {
        writeToFile(conversation);
        progress++;
        mBuilder.setProgress(conversations.size(), progress, false);
        mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Conversation(eu.siacs.conversations.entities.Conversation)

Example 92 with NotificationManager

use of android.app.NotificationManager in project routerkeygenAndroid by routerkeygen.

the class UpdateCheckerService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    final LastVersion lastVersion = getLatestVersion();
    if (lastVersion == null)
        return;
    if (!Preferences.VERSION.equals(lastVersion.version)) {
        final NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_notification).setTicker(getString(R.string.update_title)).setContentTitle(getString(R.string.update_title)).setContentText(getString(R.string.update_notification, lastVersion.version)).setOnlyAlertOnce(true).setAutoCancel(true).setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(Intent.ACTION_VIEW).setData(Uri.parse(lastVersion.url)), PendingIntent.FLAG_ONE_SHOT));
        mNotificationManager.notify(UNIQUE_ID, builder.build());
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 93 with NotificationManager

use of android.app.NotificationManager in project coursera-android by aporter.

the class AlarmNotificationReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    // The Intent to be used when the user clicks on the Notification View
    mNotificationIntent = new Intent(context, AlarmCreateActivity.class);
    // The PendingIntent that wraps the underlying Intent
    mContentIntent = PendingIntent.getActivity(context, 0, mNotificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
    // Build the Notification
    Notification.Builder notificationBuilder = new Notification.Builder(context).setTicker(tickerText).setSmallIcon(android.R.drawable.stat_sys_warning).setAutoCancel(true).setContentTitle(contentTitle).setContentText(contentText).setContentIntent(mContentIntent).setSound(soundURI).setVibrate(mVibratePattern);
    // Get the NotificationManager
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    // Pass the Notification to the NotificationManager:
    mNotificationManager.notify(MY_NOTIFICATION_ID, notificationBuilder.build());
    // Log occurence of notify() call
    Log.i(TAG, "Sending notification at:" + DateFormat.getDateTimeInstance().format(new Date()));
}
Also used : NotificationManager(android.app.NotificationManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification) Date(java.util.Date)

Example 94 with NotificationManager

use of android.app.NotificationManager in project Talon-for-Twitter by klinker24.

the class MarkReadSecondAccService method onHandleIntent.

@Override
public void onHandleIntent(Intent intent) {
    Log.v("talon_mark_read", "running the mark read service for account 2");
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);
    // clear custom light flow broadcast
    Intent lightFlow = new Intent("com.klinker.android.twitter.CLEARED_NOTIFICATION");
    this.sendBroadcast(lightFlow);
    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    final Context context = getApplicationContext();
    int currentAccount = AppSettings.getInstance(context).currentAccount;
    if (currentAccount == 1) {
        currentAccount = 2;
    } else {
        currentAccount = 1;
    }
    // we can just mark everything as read because it isnt taxing at all and won't do anything in the mentions if there isn't one
    // and the shared prefs are easy.
    // this is only called from the notification and there will only ever be one thing that is unread when this button is available
    // delay this so that if switching account, it will start at the right place
    MentionsDataSource.getInstance(context).markAllRead(currentAccount);
    HomeDataSource.getInstance(context).markAllRead(currentAccount);
    InteractionsDataSource.getInstance(context).markAllRead(currentAccount);
    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();
}
Also used : Context(android.content.Context) NotificationManager(android.app.NotificationManager) Intent(android.content.Intent)

Example 95 with NotificationManager

use of android.app.NotificationManager in project Talon-for-Twitter by klinker24.

the class MarkReadService method onHandleIntent.

@Override
public void onHandleIntent(Intent intent) {
    Log.v("talon_mark_read", "running the mark read service for account 1");
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);
    // clear custom light flow broadcast
    Intent lightFlow = new Intent("com.klinker.android.twitter.CLEARED_NOTIFICATION");
    this.sendBroadcast(lightFlow);
    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    final Context context = getApplicationContext();
    final int currentAccount = sharedPrefs.getInt("current_account", 1);
    // we can just mark everything as read because it isnt taxing at all and won't do anything in the mentions if there isn't one
    // and the shared prefs are easy.
    // this is only called from the notification and there will only ever be one thing that is unread when this button is availible
    MentionsDataSource.getInstance(context).markAllRead(currentAccount);
    HomeDataSource.getInstance(context).markAllRead(currentAccount);
    InteractionsDataSource.getInstance(context).markAllRead(currentAccount);
    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();
    startService(new Intent(this, ReadInteractionsService.class));
}
Also used : Context(android.content.Context) NotificationManager(android.app.NotificationManager) Intent(android.content.Intent)

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