List of usage examples for android.content Intent FLAG_ACTIVITY_SINGLE_TOP
int FLAG_ACTIVITY_SINGLE_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_SINGLE_TOP.
Click Source Link
From source file:com.lithiumli.fiction.PlaybackService.java
private void showNotification() { Intent launchPlaybackIntent = new Intent(getApplicationContext(), NowPlayingActivity.class); launchPlaybackIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, launchPlaybackIntent, PendingIntent.FLAG_UPDATE_CURRENT); String title = "(unknown title)"; String artist = "(unknown artist)"; String album = "(unknown album)"; Uri albumArt = Song.DEFAULT_ALBUM;/* ww w . jav a2 s .c o m*/ if (mQueue.getCount() != 0) { Song song = mQueue.getCurrent(); title = song.getTitle(); artist = song.getArtist(); album = song.getAlbum(); albumArt = song.getAlbumArt(); // TODO see ImageView.resolveUri for a working method // if (albumArt.getPath() == null) { // albumArt = Song.DEFAULT_ALBUM; // } } Notification.Builder builder = new Notification.Builder(getApplicationContext()); builder.setSmallIcon(R.drawable.ic_menu_play).setContentTitle("Playing" + title).setOngoing(true) .setContentIntent(pi); Notification notification = builder.build(); RemoteViews customView = new RemoteViews(getPackageName(), R.layout.notification); customView.setImageViewUri(R.id.notification_cover, albumArt); customView.setTextViewText(R.id.notification_title, title); customView.setTextViewText(R.id.notification_subtitle, artist); notification.contentView = customView; customView = new RemoteViews(getPackageName(), R.layout.notification_big); customView.setImageViewUri(R.id.notification_cover, albumArt); customView.setImageViewResource(R.id.notification_play_pause, mPaused ? R.drawable.ic_menu_play : R.drawable.ic_menu_pause); customView.setTextViewText(R.id.notification_title, title); customView.setTextViewText(R.id.notification_album, album); customView.setTextViewText(R.id.notification_artist, artist); customView.setOnClickPendingIntent(R.id.notification_previous, createAction(ACTION_PREV)); customView.setOnClickPendingIntent(R.id.notification_play_pause, createAction(ACTION_PLAY_PAUSE)); customView.setOnClickPendingIntent(R.id.notification_next, createAction(ACTION_NEXT)); notification.bigContentView = customView; startForeground(NOTIFICATION_PLAYING, notification); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_PLAYING, notification); }
From source file:com.google.android.apps.forscience.whistlepunk.project.ProjectDetailsFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { Intent upIntent = NavUtils.getParentActivityIntent(getActivity()); upIntent.putExtra(MainActivity.ARG_SELECTED_NAV_ITEM_ID, R.id.navigation_item_projects); upIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), mProjectCover, mProjectId); getActivity().startActivity(upIntent, options.toBundle()); return true; } else if (id == R.id.action_edit_project) { UpdateProjectActivity.launch(getActivity(), mProjectId, false /* not new */); return true; } else if (id == R.id.action_archive_project || id == R.id.action_unarchive_project) { setProjectArchived(id == R.id.action_archive_project); return true; } else if (id == R.id.action_delete_project) { confirmDelete();/* w w w. j av a2 s .co m*/ return true; } else if (id == R.id.action_include_archived) { item.setChecked(!item.isChecked()); mIncludeArchived = item.isChecked(); loadExperiments(); return true; } return super.onOptionsItemSelected(item); }
From source file:de.linuxwhatelse.android.notify.activities.MainActivity.java
private void handleSnoozedNotification() { this.initChannels(this, getString(R.string.notification_channel_snooze)); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); boolean notificationsSnoozed = preferences.getBoolean(Notify.PREFERENCE_KEY_NOTIFICATIONS_SNOOZED, false); boolean eventsSnoozed = preferences.getBoolean(Notify.PREFERENCE_KEY_EVENTS_SNOOZED, false); long snoozeUntil = preferences.getLong(Notify.PREFERENCE_KEY_SNOOZED_UNTIL, -1); if (!notificationsSnoozed && !eventsSnoozed) { notificationManager.cancel(Notify.NOTIFICATION_ID_SNOOZE); return;/*from www. j ava2 s . c o m*/ } String title = getString(R.string.snoozed_notifications_title); if (notificationsSnoozed && eventsSnoozed) { title = getString(R.string.snoozed_all_title); } String body = getString(R.string.snoozed_text_resume_indefinitely); if (snoozeUntil != -1) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(snoozeUntil); String day = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()); String time = (new SimpleDateFormat("HH:mm", getResources().getConfiguration().locale)) .format(cal.getTime()); body = getString(R.string.snoozed_text_resume_at) + " " + day + " " + time; } Intent activityIntent = new Intent(context, MainActivity.class); activityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent activityPendingIntent = PendingIntent.getActivity(context, 0, activityIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, Notify.NOTIFICATION_CHANNEL) .setContentTitle(title).setContentText(body).setSmallIcon(R.drawable.ic_notifications_paused) .setPriority(NotificationCompat.PRIORITY_LOW).setContentIntent(activityPendingIntent) .setOngoing(true); Intent intent = new Intent(getApplicationContext(), SnoozeEndReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_notifications_active, getString(R.string.snoozed_action_resume), pendingIntent).build(); mBuilder.addAction(action); notificationManager.notify(Notify.NOTIFICATION_ID_SNOOZE, mBuilder.build()); }
From source file:kashmirr.social.service.NotificationService.java
public void sendFriendRequestNotification(Context context, String requesterName, String requestId) { NotificationManager notificationManagerCompat = (NotificationManager) context .getSystemService(NOTIFICATION_SERVICE); Intent requestsViewIntent = new Intent(context, RequestsView.class); requestsViewIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent requestsViewPending = PendingIntent.getActivity(context, Integer.valueOf(requestId), requestsViewIntent, 0);//w w w . j a va2s. c o m android.support.v7.app.NotificationCompat.Builder builder = new android.support.v7.app.NotificationCompat.Builder( context); builder.setSmallIcon(R.drawable.ic_account_multiple_plus_white_24dp); builder.setAutoCancel(true); builder.setContentTitle(requesterName + " " + getString(R.string.tobeFriend)); builder.setContentText(getString(R.string.toViewTheRequest)); builder.setGroup(GROUP_KEY_MESSAGES); builder.setDefaults(android.app.Notification.DEFAULT_ALL); builder.setContentIntent(requestsViewPending); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.toViewTheRequest))); builder.setShowWhen(true); android.app.Notification notification = builder.build(); notificationManagerCompat.notify(Integer.valueOf(requestId), notification); }
From source file:net.simno.klingar.MediaNotificationManager.java
private PendingIntent createContentIntent() { Intent intent = new Intent(service, KlingarActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); return PendingIntent.getActivity(service, REQUEST_CODE, intent, FLAG_CANCEL_CURRENT); }
From source file:net.iamyellow.gcmjs.GcmjsModule.java
/** * Create big style notification//from w w w . j a va 2s.c o m * @param ntfId : counter for number of unread notification * @param title : notification title * @param message : notification body message * @param tickerText : notification text that appears on notification area when closed * @param icon : icon that will appear beside the notification * @param notificationId : unique notification id */ @Kroll.method public void createBigNotificationStyle(int ntfId, String title, String message, String tickerText, int icon, int notificationId) { Intent intent = new Intent(); intent.setAction("action" + ntfId); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setClassName(TiApplication.getInstance().getApplicationContext().getPackageName(), TiApplication.getInstance().getPackageManager() .getLaunchIntentForPackage(TiApplication.getInstance().getPackageName()).getComponent() .getClassName()); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.putExtra("ntfId", ntfId); PendingIntent pintent = PendingIntent.getActivity(TiApplication.getInstance().getApplicationContext(), 0, intent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder( TiApplication.getInstance().getApplicationContext()).setContentIntent(pintent).setSmallIcon(icon) .setContentTitle(title).setContentText(message).setTicker(tickerText).setAutoCancel(true) .setNumber(ntfId) // .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE // permission /* * Sets the big view "big text" style and supplies the text (the * user's reminder message) that will be displayed in the detail * area of the expanded notification. These calls are ignored by * the support library for pre-4.1 devices. */ .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); NotificationManager mNotificationManager = (NotificationManager) TiApplication.getInstance() .getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); // notificationId allows you to update the notification later on. mNotificationManager.notify(notificationId, builder.build()); }
From source file:im.vector.activity.CommonActivityUtils.java
public static void goToRoomPage(final MXSession aSession, final String roomId, final Activity fromActivity, final Intent intentParam) { // check first if the 1:1 room already exists MXSession session = (aSession == null) ? Matrix.getMXSession(fromActivity, null) : aSession; // sanity check if ((null == session) || !session.isActive()) { return;/* w ww. ja va2 s . c o m*/ } final MXSession fSession = session; Room room = session.getDataHandler().getRoom(roomId); // do not open a leaving room. // it does not make. if ((null != room) && (room.isLeaving())) { return; } fromActivity.runOnUiThread(new Runnable() { @Override public void run() { // if the activity is not the home activity if (!(fromActivity instanceof HomeActivity)) { // pop to the home activity Intent intent = new Intent(fromActivity, HomeActivity.class); intent.setFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP | android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(HomeActivity.EXTRA_JUMP_TO_ROOM_ID, roomId); intent.putExtra(HomeActivity.EXTRA_JUMP_MATRIX_ID, fSession.getCredentials().userId); if (null != intentParam) { intent.putExtra(HomeActivity.EXTRA_ROOM_INTENT, intentParam); } fromActivity.startActivity(intent); } else { // already to the home activity // so just need to open the room activity Intent intent = new Intent(fromActivity, RoomActivity.class); intent.putExtra(RoomActivity.EXTRA_ROOM_ID, roomId); intent.putExtra(RoomActivity.EXTRA_MATRIX_ID, fSession.getCredentials().userId); if (null != intentParam) { intent.putExtra(HomeActivity.EXTRA_ROOM_INTENT, intentParam); } fromActivity.startActivity(intent); } } }); }
From source file:com.ayogo.cordova.notification.ScheduledNotificationManager.java
public void showNotification(ScheduledNotification scheduledNotification) { LOG.v(NotificationPlugin.TAG, "showNotification: " + scheduledNotification.toString()); NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); // Build the notification options builder.setDefaults(Notification.DEFAULT_ALL).setTicker(scheduledNotification.body) .setPriority(Notification.PRIORITY_HIGH).setAutoCancel(true); // TODO: add sound support // if (scheduledNotification.sound != null) { // builder.setSound(sound); // }/*from www . j ava 2 s .c o m*/ if (scheduledNotification.body != null) { builder.setContentTitle(scheduledNotification.title); builder.setContentText(scheduledNotification.body); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(scheduledNotification.body)); } else { //Default the title to the app name try { PackageManager pm = context.getPackageManager(); ApplicationInfo applicationInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); String appName = applicationInfo.loadLabel(pm).toString(); builder.setContentTitle(appName); builder.setContentText(scheduledNotification.title); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(scheduledNotification.title)); } catch (NameNotFoundException e) { LOG.v(NotificationPlugin.TAG, "Failed to set title for notification!"); return; } } if (scheduledNotification.badge != null) { LOG.v(NotificationPlugin.TAG, "showNotification: has a badge!"); builder.setSmallIcon(getResIdForDrawable(scheduledNotification.badge)); } else { LOG.v(NotificationPlugin.TAG, "showNotification: has no badge, use app icon!"); try { PackageManager pm = context.getPackageManager(); ApplicationInfo applicationInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Resources resources = pm.getResourcesForApplication(applicationInfo); builder.setSmallIcon(applicationInfo.icon); } catch (NameNotFoundException e) { LOG.v(NotificationPlugin.TAG, "Failed to set badge for notification!"); return; } } if (scheduledNotification.icon != null) { LOG.v(NotificationPlugin.TAG, "showNotification: has an icon!"); builder.setLargeIcon(getIconFromUri(scheduledNotification.icon)); } else { LOG.v(NotificationPlugin.TAG, "showNotification: has no icon, use app icon!"); try { PackageManager pm = context.getPackageManager(); ApplicationInfo applicationInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Resources resources = pm.getResourcesForApplication(applicationInfo); Bitmap appIconBitmap = BitmapFactory.decodeResource(resources, applicationInfo.icon); builder.setLargeIcon(appIconBitmap); } catch (NameNotFoundException e) { LOG.v(NotificationPlugin.TAG, "Failed to set icon for notification!"); return; } } Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); launchIntent.setAction("notification"); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(contentIntent); Notification notification = builder.build(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); LOG.v(NotificationPlugin.TAG, "notify!"); notificationManager.notify(scheduledNotification.tag.hashCode(), notification); }
From source file:com.open.file.manager.CutCopyService.java
@Override protected void onHandleIntent(Intent intent) { progressview = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbarlayout); currentaction = intent.getIntExtra("action", 0); filelist = intent.getStringArrayListExtra("filelist"); targetfolder = new File(intent.getStringExtra("targetfolder")); tree = new FileCopyTree(filelist, targetfolder); duplicates = null;// ww w . ja v a 2 s . c o m currentfileind = 0; progressbytes = 0; progresspercent = 0; totalbytes = tree.size; mHandler = new dupresponcehandler(this); if (tree.duplicates.size() != 0) { sendDuplicateMessage(); } id = 1; completeid = (completeid + 2) % Integer.MAX_VALUE; cutcopymanager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); cutcopybuilder = new NotificationCompat.Builder(this); // cutcopybuilder.setProgress(100, 0, false); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); cutcopybuilder .setContent(new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbarlayout)); cutcopybuilder.setSmallIcon(R.drawable.notifyicon); actiongerund = getResources().getString(actioning[currentaction]); cutcopybuilder.setContentTitle(actiongerund + " files"); cutcopybuilder.setContentIntent(contentIntent); cutcopynotification = cutcopybuilder.build(); cutcopynotification.contentView = progressview; cutcopynotification.contentView.setProgressBar(R.id.progressBar, 100, 0, false); cutcopynotification.contentView.setTextViewText(R.id.progresstext, actiongerund + " files"); cutcopymanager.notify(id, cutcopynotification); startForeground(id, cutcopynotification); performCutCopy(); }
From source file:com.klinker.android.twitter.utils.NotificationUtils.java
public static void refreshNotification(Context context, boolean noTimeline) { AppSettings settings = AppSettings.getInstance(context); SharedPreferences sharedPrefs = context.getSharedPreferences( "com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); int currentAccount = sharedPrefs.getInt("current_account", 1); //int[] unreadCounts = new int[] {4, 1, 2}; // for testing int[] unreadCounts = getUnreads(context); int timeline = unreadCounts[0]; int realTimelineCount = timeline; // if they don't want that type of notification, simply set it to zero if (!settings.timelineNot || (settings.pushNotifications && settings.liveStreaming) || noTimeline) { unreadCounts[0] = 0;// w w w. j av a 2s . c o m } if (!settings.mentionsNot) { unreadCounts[1] = 0; } if (!settings.dmsNot) { unreadCounts[2] = 0; } if (unreadCounts[0] == 0 && unreadCounts[1] == 0 && unreadCounts[2] == 0) { } else { Intent markRead = new Intent(context, MarkReadService.class); PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0); String shortText = getShortText(unreadCounts, context, currentAccount); String longText = getLongText(unreadCounts, context, currentAccount); // [0] is the full title and [1] is the screenname String[] title = getTitle(unreadCounts, context, currentAccount); boolean useExpanded = useExp(context); boolean addButton = addBtn(unreadCounts); if (title == null) { return; } Intent resultIntent; if (unreadCounts[1] != 0 && unreadCounts[0] == 0) { // it is a mention notification (could also have a direct message) resultIntent = new Intent(context, RedirectToMentions.class); } else if (unreadCounts[2] != 0 && unreadCounts[0] == 0 && unreadCounts[1] == 0) { // it is a direct message resultIntent = new Intent(context, RedirectToDMs.class); } else { resultIntent = new Intent(context, MainActivity.class); } PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0); NotificationCompat.Builder mBuilder; Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class); mBuilder = new NotificationCompat.Builder(context).setContentTitle(title[0]) .setContentText(TweetLinkUtils.removeColorHtml(shortText, settings)) .setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(getIcon(context, unreadCounts, title[1])) .setContentIntent(resultPendingIntent).setAutoCancel(true) .setTicker(TweetLinkUtils.removeColorHtml(shortText, settings)) .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0)) .setPriority(NotificationCompat.PRIORITY_HIGH); if (unreadCounts[1] > 1 && unreadCounts[0] == 0 && unreadCounts[2] == 0) { // inbox style notification for mentions mBuilder.setStyle(getMentionsInboxStyle(unreadCounts[1], currentAccount, context, TweetLinkUtils.removeColorHtml(shortText, settings))); } else if (unreadCounts[2] > 1 && unreadCounts[0] == 0 && unreadCounts[1] == 0) { // inbox style notification for direct messages mBuilder.setStyle(getDMInboxStyle(unreadCounts[1], currentAccount, context, TweetLinkUtils.removeColorHtml(shortText, settings))); } else { // big text style for an unread count on timeline, mentions, and direct messages mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml( settings.addonTheme ? longText.replaceAll("FF8800", settings.accentColor) : longText))); } // Pebble notification if (sharedPrefs.getBoolean("pebble_notification", false)) { sendAlertToPebble(context, title[0], shortText); } // Light Flow notification sendToLightFlow(context, title[0], shortText); int homeTweets = unreadCounts[0]; int mentionsTweets = unreadCounts[1]; int dmTweets = unreadCounts[2]; int newC = 0; if (homeTweets > 0) { newC++; } if (mentionsTweets > 0) { newC++; } if (dmTweets > 0) { newC++; } if (settings.notifications && newC > 0) { if (settings.vibrate) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } if (settings.sound) { try { mBuilder.setSound(Uri.parse(settings.ringtone)); } catch (Exception e) { mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); } } if (settings.led) mBuilder.setLights(0xFFFFFF, 1000, 1000); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); if (addButton) { // the reply and read button should be shown Intent reply; if (unreadCounts[1] == 1) { reply = new Intent(context, NotificationCompose.class); } else { reply = new Intent(context, NotificationDMCompose.class); } Log.v("username_for_noti", title[1]); sharedPrefs.edit().putString("from_notification", "@" + title[1] + " " + title[2]).commit(); MentionsDataSource data = MentionsDataSource.getInstance(context); long id = data.getLastIds(currentAccount)[0]; PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0); sharedPrefs.edit().putLong("from_notification_long", id).commit(); sharedPrefs.edit() .putString("from_notification_text", "@" + title[1] + ": " + TweetLinkUtils.removeColorHtml(shortText, settings)) .commit(); // Create the remote input RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel("@" + title[1] + " ").build(); // Create the notification action NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder( R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply), replyPending).addRemoteInput(remoteInput).build(); NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder( R.drawable.ic_action_read_dark, context.getResources().getString(R.string.mark_read), readPending); mBuilder.addAction(replyAction); mBuilder.addAction(action.build()); } else { // otherwise, if they can use the expanded notifications, the popup button will be shown Intent popup = new Intent(context, RedirectToPopup.class); popup.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); popup.putExtra("from_notification", true); PendingIntent popupPending = PendingIntent.getActivity(context, 0, popup, 0); NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder( R.drawable.ic_popup, context.getResources().getString(R.string.popup), popupPending); mBuilder.addAction(action.build()); } // Build the notification and issues it with notification manager. notificationManager.notify(1, mBuilder.build()); // if we want to wake the screen on a new message if (settings.wakeScreen) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); wakeLock.acquire(5000); } } // if there are unread tweets on the timeline, check them for favorite users if (settings.favoriteUserNotifications && realTimelineCount > 0) { favUsersNotification(currentAccount, context); } } try { ContentValues cv = new ContentValues(); cv.put("tag", "com.klinker.android.twitter/com.klinker.android.twitter.ui.MainActivity"); // add the direct messages and mentions cv.put("count", unreadCounts[1] + unreadCounts[2]); context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); } catch (IllegalArgumentException ex) { /* Fine, TeslaUnread is not installed. */ } catch (Exception ex) { /* Some other error, possibly because the format of the ContentValues are incorrect. Log but do not crash over this. */ ex.printStackTrace(); } }