Java Code Examples for android.support.v4.app.NotificationCompat.Builder#setTicker()
The following examples show how to use
android.support.v4.app.NotificationCompat.Builder#setTicker() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationService.java From Klyph with MIT License | 5 votes |
private void sendNotification(final Notification notification, final boolean sendDetails) { final Builder builder = KlyphNotification.getBuilder(service.get(), true); builder.setContentTitle(notification.getSender_name()); builder.setContentText(notification.getTitle_text()); builder.setTicker(String.format("%1$s\n%2$s", notification.getSender_name(), notification.getTitle_text())); ImageLoader.loadImage(notification.getSender_pic(), new SimpleFakeImageLoaderListener() { @Override public void onBitmapFailed(Drawable drawable) { if (sendDetails) KlyphNotification.sendNotification(service.get(), builder, notification); else KlyphNotification.sendNotification(service.get(), builder); } @Override public void onBitmapLoaded(Bitmap bitmap, LoadedFrom arg1) { builder.setLargeIcon(bitmap); if (sendDetails) KlyphNotification.sendNotification(service.get(), builder, notification); else KlyphNotification.sendNotification(service.get(), builder); } }); }
Example 2
Source File: NotificationService.java From Conversations with GNU General Public License v3.0 | 5 votes |
private void modifyForImage(final Builder builder, final Message message, final ArrayList<Message> messages) { try { final Bitmap bitmap = mXmppConnectionService.getFileBackend().getThumbnail(message, getPixel(288), false); final ArrayList<Message> tmp = new ArrayList<>(); for (final Message msg : messages) { if (msg.getType() == Message.TYPE_TEXT && msg.getTransferable() == null) { tmp.add(msg); } } final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle(); bigPictureStyle.bigPicture(bitmap); if (tmp.size() > 0) { CharSequence text = getMergedBodies(tmp); bigPictureStyle.setSummaryText(text); builder.setContentText(text); builder.setTicker(text); } else { final String description = UIHelper.getFileDescriptionString(mXmppConnectionService, message); builder.setContentText(description); builder.setTicker(description); } builder.setStyle(bigPictureStyle); } catch (final IOException e) { modifyForTextOnly(builder, messages); } }
Example 3
Source File: SipNotifications.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
public synchronized void notifyRegisteredAccounts(ArrayList<SipProfileState> activeAccountsInfos, boolean showNumbers) { if (!isServiceWrapper) { Log.e(THIS_FILE, "Trying to create a service notification from outside the service"); return; } int icon = R.drawable.ic_stat_sipok; CharSequence tickerText = context.getString(R.string.service_ticker_registered_text); long when = System.currentTimeMillis(); Builder nb = new Builder(context); nb.setSmallIcon(icon); nb.setTicker(tickerText); nb.setWhen(when); Intent notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); RegistrationNotification contentView = new RegistrationNotification(context.getPackageName()); contentView.clearRegistrations(); if(!Compatibility.isCompatible(9)) { contentView.setTextsColor(notificationPrimaryTextColor); } contentView.addAccountInfos(context, activeAccountsInfos); // notification.setLatestEventInfo(context, contentTitle, // contentText, contentIntent); nb.setOngoing(true); nb.setOnlyAlertOnce(true); nb.setContentIntent(contentIntent); nb.setContent(contentView); Notification notification = nb.build(); notification.flags |= Notification.FLAG_NO_CLEAR; // We have to re-write content view because getNotification setLatestEventInfo implicitly notification.contentView = contentView; if (showNumbers) { // This only affects android 2.3 and lower notification.number = activeAccountsInfos.size(); } startForegroundCompat(REGISTER_NOTIF_ID, notification); }
Example 4
Source File: IMNotificationManager.java From sctalk with Apache License 2.0 | 4 votes |
private void showInNotificationBar(String title,String ticker, Bitmap iconBitmap,int notificationId,Intent intent) { logger.d("notification#showInNotificationBar title:%s ticker:%s",title,ticker); NotificationManager notifyMgr = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); if (notifyMgr == null) { return; } Builder builder = new NotificationCompat.Builder(ctx); builder.setContentTitle(title); builder.setContentText(ticker); builder.setSmallIcon(R.drawable.tt_small_icon); builder.setTicker(ticker); builder.setWhen(System.currentTimeMillis()); builder.setAutoCancel(true); // this is the content near the right bottom side // builder.setContentInfo("content info"); if (configurationSp.getCfg(SysConstant.SETTING_GLOBAL,ConfigurationSp.CfgDimension.VIBRATION)) { // delay 0ms, vibrate 200ms, delay 250ms, vibrate 200ms long[] vibrate = {0, 200, 250, 200}; builder.setVibrate(vibrate); } else { logger.d("notification#setting is not using vibration"); } // sound if (configurationSp.getCfg(SysConstant.SETTING_GLOBAL,ConfigurationSp.CfgDimension.SOUND)) { builder.setDefaults(Notification.DEFAULT_SOUND); } else { logger.d("notification#setting is not using sound"); } if (iconBitmap != null) { logger.d("notification#fetch icon from network ok"); builder.setLargeIcon(iconBitmap); } else { // do nothint ? } // if MessageActivity is in the background, the system would bring it to // the front intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(ctx, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); Notification notification = builder.build(); notifyMgr.notify(notificationId, notification); }
Example 5
Source File: FriendRequestService.java From Klyph with MIT License | 4 votes |
private void onRequestSuccess(List<GraphObject> list) { Log.d("FriendRequestService", "Num friend request : " + list.size()); Log.d("FriendRequestService", "Service : " + service.get()); if (service.get() == null) return; Service s = service.get(); if (list.size() > 0) { FriendRequest fq = (FriendRequest) list.get(0); KlyphPreferences.setFriendRequestServiceOffset(fq.getTime()); final Builder builder = KlyphNotification.getBuilder(s, true); builder.setContentTitle(fq.getUid_from_name()).setContentText( s.getString(R.string.notification_friendrequest_message, fq.getUid_from_name())); if (KlyphPreferences.mustGroupNotifications() && list.size() > 1) { sendNotification(list); } else { boolean isFirst = true; for (GraphObject graphObject : list) { FriendRequest fr = (FriendRequest) graphObject; TaskStackBuilder stackBuilder = TaskStackBuilder.create(service.get()); Intent intent = Klyph.getIntentForGraphObject(service.get(), fr); // stackBuilder.addParentStack(UserActivity.class); Intent mainIntent = new Intent(service.get(), MainActivity.class); mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); stackBuilder.addNextIntent(mainIntent); stackBuilder.addNextIntent(intent); int intentCode = (int) Math.round(Math.random() * 1000000); // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(intentCode, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(resultPendingIntent); builder.setContentTitle(fr.getUid_from_name()); builder.setContentText(s.getString(R.string.notification_friendrequest_message, fr.getUid_from_name())); builder.setTicker(s.getString(R.string.notification_friendrequest_message, fr.getUid_from_name())); if (isFirst == false) { KlyphNotification.setNoSound(builder); KlyphNotification.setNoVibration(builder); } KlyphNotification.sendNotification(s, builder); isFirst = false; } } service.get().stopSelf(); } else { s.stopSelf(); } }