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());
}
}
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());
}
}
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()));
}
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();
}
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));
}
Aggregations