List of usage examples for android.app Notification PRIORITY_DEFAULT
int PRIORITY_DEFAULT
To view the source code for android.app Notification PRIORITY_DEFAULT.
Click Source Link
From source file:ca.zadrox.dota2esportticker.service.ReminderAlarmService.java
private void notifyDebug() { final Resources res = getResources(); String contentTitle = "Debug Notification"; String contentText;/*from w w w . j a v a 2 s . c o m*/ long currentTime = TimeUtils.getUTCTime(); long matchStart = TimeUtils.getUTCTime() + 60000; int minutesLeft = (int) (matchStart - currentTime + 59000) / 60000; if (minutesLeft < 2 && minutesLeft >= 0) { minutesLeft = 1; } if (minutesLeft < 0) { contentText = "debugNotification"; } else { contentText = "debugNotification"; } NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this).setContentTitle(contentTitle) .setContentText(contentText).setColor(res.getColor(R.color.theme_primary)) .setTicker(contentTitle + " is about to start.") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(NOTIFICATION_ARGB_COLOR, NOTIFICATION_LED_ON_MS, NOTIFICATION_LED_OFF_MS) .setSmallIcon(R.drawable.ic_notification).setPriority(Notification.PRIORITY_DEFAULT) .setAutoCancel(true); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, notifBuilder.build()); }
From source file:ti.modules.titanium.audio.streamer.NotificationHelper.java
/** * Call this to build the {@link Notification}. *///from w w w . ja v a 2 s .c o m public void buildNotification() { // Default notfication layout if (mViewId == 0 && mExpandedViewId == 0) { return; } try { mDrawablePlay = TiRHelper.getResource("drawable." + NOTIFICATION_DRAWBLE_PLAY); mDrawablePause = TiRHelper.getResource("drawable." + NOTIFICATION_DRAWBLE_PAUSE); } catch (ResourceNotFoundException e1) { } if (mViewId > 0) { mView = new RemoteViews(mService.getPackageName(), mViewId); try { id_notification_base_title = TiRHelper.getResource("id." + NOTIFICATION_BASE_TITLE); id_notification_base_artist = TiRHelper.getResource("id." + NOTIFICATION_BASE_ARTIST); id_notification_base_album = TiRHelper.getResource("id." + NOTIFICATION_BASE_ALBUM); id_notification_base_image = TiRHelper.getResource("id." + NOTIFICATION_BASE_IMAGE); id_notification_base_play = TiRHelper.getResource("id." + NOTIFICATION_BASE_PLAY); id_notification_base_prev = TiRHelper.getResource("id." + NOTIFICATION_BASE_PREV); id_notification_base_next = TiRHelper.getResource("id." + NOTIFICATION_BASE_NEXT); } catch (ResourceNotFoundException e) { } // Set up the content view // initCollapsedLayout(trackName, albumName, artistName, albumArt); } if (HONEYCOMB_OR_GREATER) { // Notification Builder mNotification = new NotificationCompat.Builder(mService).setSmallIcon(mIcon) .setContentIntent(getPendingIntent()).setOngoing(true) .setPriority(Notification.PRIORITY_DEFAULT).setContent(mView).build(); // Control playback from the notification initPlaybackActions(); if (JELLY_BEAN_OR_GREATER) { // Expanded notifiction style mExpandedView = new RemoteViews(mService.getPackageName(), mExpandedViewId); try { id_notification_expanded_title = TiRHelper.getResource("id." + NOTIFICATION_EXPANDED_TITLE); id_notification_expanded_artist = TiRHelper.getResource("id." + NOTIFICATION_EXPANDED_ARTIST); id_notification_expanded_album = TiRHelper.getResource("id." + NOTIFICATION_EXPANDED_ALBUM); id_notification_expanded_image = TiRHelper.getResource("id." + NOTIFICATION_EXPANDED_IMAGE); id_notification_expanded_play = TiRHelper.getResource("id." + NOTIFICATION_EXPANDED_PLAY); id_notification_expanded_prev = TiRHelper.getResource("id." + NOTIFICATION_EXPANDED_PREV); id_notification_expanded_next = TiRHelper.getResource("id." + NOTIFICATION_EXPANDED_NEXT); id_notification_expanded_collapse = TiRHelper .getResource("id." + NOTIFICATION_EXPANDED_COLLAPSE); } catch (ResourceNotFoundException e) { } mNotification.bigContentView = mExpandedView; // Control playback from the notification initExpandedPlaybackActions(); // Set up the expanded content view // initExpandedLayout(trackName, albumName, artistName, // albumArt); } mService.startForeground(mNotificationId, mNotification); } else { Builder notificationBuilder = new NotificationCompat.Builder(mService); notificationBuilder.setSmallIcon(mIcon); notificationBuilder.setContentIntent(getPendingIntent()); notificationBuilder.setOngoing(true); mNotification = notificationBuilder.build(); mNotification.contentView = mView; if (JELLY_BEAN_OR_GREATER) { mNotification.bigContentView = mExpandedView; } mService.startForeground(mNotificationId, mNotification); } }
From source file:com.abhinavjhanwar.android.egg.neko.Cat.java
public Notification.Builder buildNotification(Context context) { final Bundle extras = new Bundle(); extras.putString("android.substName", context.getString(R.string.app_name)); final Intent intent = new Intent(Intent.ACTION_MAIN).setClass(context, NekoLand.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return new Notification.Builder(context) .setSmallIcon(Icon.createWithResource(context, R.drawable.stat_icon)) .setLargeIcon(createLargeIcon(context)).setColor(getBodyColor()) .setPriority(Notification.PRIORITY_DEFAULT).setContentTitle(NekoService.notificationText) .setShowWhen(true).setCategory(Notification.CATEGORY_STATUS).setContentText(getName()) .setContentIntent(PendingIntent.getActivity(context, 0, intent, 0)).setAutoCancel(true) .setVibrate(PURR).addExtras(extras); }/*from w w w. j av a 2 s. c o m*/ return new Notification.Builder(context).setSmallIcon(R.drawable.stat_icon) .setPriority(Notification.PRIORITY_DEFAULT).setContentTitle(OldService.notificationText) .setContentText(getName()).setContentIntent(PendingIntent.getActivity(context, 0, intent, 0)) .setAutoCancel(true).setVibrate(PURR); }
From source file:es.usc.citius.servando.calendula.activities.ReminderNotification.java
private static Notification buildNotification(Context context, NotificationOptions options) { Resources res = context.getResources(); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context) // Set appropriate defaults for the notification light, sound, and vibration. .setDefaults(Notification.DEFAULT_ALL) // Set required fields, including the small icon, the notification title, and text. .setSmallIcon(R.drawable.ic_pill_small).setContentTitle(options.title).setContentText(options.text) .setPriority(// www . j a v a2 s . c om options.insistent ? NotificationCompat.PRIORITY_MAX : NotificationCompat.PRIORITY_DEFAULT) // Provide a large icon, shown with the notification in the // notification drawer on devices running Android 3.0 or later. .setLargeIcon(options.picture) // Set ticker text (preview) information for this notification. .setTicker(options.ticker) // Show a number. This is useful when stacking notifications of a single type. .setNumber(options.notificationNumber).setWhen(options.when) // Set the pending intent to be initiated when the user touches the notification. .setContentIntent(options.defaultIntent) //.setOngoing(true) // add delay button .addAction(R.drawable.ic_history_white_24dp, res.getString(R.string.notification_delay), options.delayIntent) .addAction(R.drawable.ic_alarm_off_white_24dp, res.getString(R.string.notification_cancel_now), options.cancelIntent) // Show an expanded list of items on devices running Android 4.1 // or later. .setStyle(options.style) //.setLights(0x00ff0000, 500, 1000) .setPriority(Notification.PRIORITY_DEFAULT) .setVibrate(new long[] { 1000, 200, 500, 200, 100, 200, 1000 }).setSound(options.ringtone) // Automatically dismiss the notification when it is touched. .setAutoCancel(true); if (options.insistent) { builder.setFullScreenIntent(options.defaultIntent, true); } Notification n = builder.build(); n.defaults = 0; n.ledARGB = 0x00ffa500; n.ledOnMS = 1000; n.ledOffMS = 2000; if (options.insistent) { n.flags |= Notification.FLAG_INSISTENT; } return n; }
From source file:ca.zadrox.dota2esportticker.service.ReminderAlarmService.java
private void notifyMatch(long matchId) { if (!PrefUtils.shouldShowMatchReminders(this)) { return;/* w w w.j a v a 2 s . c om*/ } final ContentResolver cr = getContentResolver(); Cursor c = cr.query(MatchContract.SeriesEntry.CONTENT_URI, MatchDetailQuery.PROJECTION, SESSION_ID_WHERE_CLAUSE, new String[] { String.valueOf(matchId) }, null); if (!c.moveToNext()) { return; } Intent baseIntent = new Intent(this, MatchActivity.class); baseIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); TaskStackBuilder taskBuilder = TaskStackBuilder.create(this).addNextIntent(baseIntent); Intent matchIntent = new Intent(this, MatchDetailActivity.class); matchIntent.putExtra(MatchDetailActivity.ARGS_GG_MATCH_ID, matchId); taskBuilder.addNextIntent(matchIntent); PendingIntent pi = taskBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); final Resources res = getResources(); String contentTitle = c.getString(MatchDetailQuery.TEAM_ONE_NAME) + " vs " + c.getString(MatchDetailQuery.TEAM_TWO_NAME); String contentText; long currentTime = TimeUtils.getUTCTime(); long matchStart = c.getLong(MatchDetailQuery.DATE_TIME); int minutesLeft = (int) (matchStart - currentTime + 59000) / 60000; if (minutesLeft < 2 && minutesLeft >= 0) { minutesLeft = 1; } if (minutesLeft < 0) { contentText = "is scheduled to start now. (" + c.getString(MatchDetailQuery.TOURNAMENT_NAME) + ")"; } else { contentText = "is scheduled to start in " + minutesLeft + " min. (" + c.getString(MatchDetailQuery.TOURNAMENT_NAME) + ")"; } NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this).setContentTitle(contentTitle) .setContentText(contentText).setColor(res.getColor(R.color.theme_primary)) .setTicker(contentTitle + " is about to start.") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(NOTIFICATION_ARGB_COLOR, NOTIFICATION_LED_ON_MS, NOTIFICATION_LED_OFF_MS) .setSmallIcon(R.drawable.ic_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_DEFAULT).setAutoCancel(true); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, notifBuilder.build()); }
From source file:de.baumann.hhsmoodle.data_todo.Todo_Fragment.java
public void setTodoList() { if (isFABOpen) { closeFABMenu();/*from ww w . java 2s .co m*/ } NotificationManager nMgr = (NotificationManager) getActivity() .getSystemService(Context.NOTIFICATION_SERVICE); nMgr.cancelAll(); //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "todo_title", "todo_content", "todo_creation" }; final Cursor row = db.fetchAllData(getActivity()); adapter = new SimpleCursorAdapter(getActivity(), layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); helper_main.switchIcon(getActivity(), todo_icon, "todo_icon", iv_icon); switch (todo_attachment) { case "true": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle_red); int n = Integer.valueOf(_id); android.content.Intent iMain = new android.content.Intent(); iMain.setAction("shortcutToDo"); iMain.setClassName(getActivity(), "de.baumann.hhsmoodle.activities.Activity_splash"); PendingIntent piMain = PendingIntent.getActivity(getActivity(), n, iMain, 0); NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(getActivity()) .setSmallIcon(R.drawable.school) .setColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary)) .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain); Notification notification = new NotificationCompat.Builder(getActivity()) .setColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary)) .setSmallIcon(R.drawable.school).setContentTitle(todo_title) .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true) .setGroup("HHS_Moodle") .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content)) .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build(); NotificationManager notificationManager = (NotificationManager) getActivity() .getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(n, notification); notificationManager.notify(0, builderSummary.build()); break; } iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final helper_main.Item[] items = { new helper_main.Item(getString(R.string.note_priority_0), R.drawable.circle_green), new helper_main.Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new helper_main.Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<helper_main.Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), todo_title, todo_content, "3", todo_attachment, todo_creation); setTodoList(); } else if (item == 1) { db.update(Integer.parseInt(_id), todo_title, todo_content, "2", todo_attachment, todo_creation); setTodoList(); } else if (item == 2) { db.update(Integer.parseInt(_id), todo_title, todo_content, "1", todo_attachment, todo_creation); setTodoList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { switch (todo_attachment) { case "true": db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "", todo_creation); setTodoList(); break; default: db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "true", todo_creation); setTodoList(); break; } } }); return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_todoBY", "note_title"); sharedPref.edit().putString("filter_todoBY", "note_title").apply(); filter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return db.fetchDataByFilter(constraint.toString(), note_search); } }); lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { if (isFABOpen) { closeFABMenu(); } Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); sharedPref.edit().putString("toDo_title", todo_title).apply(); sharedPref.edit().putString("toDo_text", todo_content).apply(); sharedPref.edit().putString("toDo_seqno", _id).apply(); sharedPref.edit().putString("toDo_icon", todo_icon).apply(); sharedPref.edit().putString("toDo_create", todo_creation).apply(); sharedPref.edit().putString("toDo_attachment", todo_attachment).apply(); helper_main.switchToActivity(getActivity(), Activity_todo.class, false); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (isFABOpen) { closeFABMenu(); } Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); final CharSequence[] options = { getString(R.string.number_edit_entry), getString(R.string.bookmark_remove_bookmark), getString(R.string.todo_share), getString(R.string.bookmark_createNote), getString(R.string.count_create), getString(R.string.bookmark_createEvent) }; new AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.number_edit_entry))) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_title, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setHint(R.string.bookmark_edit_title); edit_title.setText(todo_title); builder.setView(dialogView); builder.setTitle(R.string.bookmark_edit_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); db.update(Integer.parseInt(_id), inputTag, todo_content, todo_icon, todo_attachment, todo_creation); setTodoList(); Snackbar.make(lv, R.string.bookmark_added, Snackbar.LENGTH_SHORT).show(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(getActivity(), edit_title); } if (options[item].equals(getString(R.string.todo_share))) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, todo_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, todo_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.bookmark_createEvent))) { helper_main.createCalendarEvent(getActivity(), todo_title, todo_content); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setTodoList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.bookmark_createNote))) { Notes_helper.newNote(getActivity(), todo_title, todo_content, "", "", "", ""); } if (options[item].equals(getString(R.string.count_create))) { Count_helper.newCount(getActivity(), todo_title, todo_content, getActivity().getString(R.string.note_content), false); } } }).show(); return true; } }); }
From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static Notification makePinNotification(Context context, Builder builder, ContentSet task, boolean withSound, boolean withTickerText, boolean withHeadsUpNotification) { Resources resources = context.getResources(); // reset actions builder.mActions = new ArrayList<Action>(2); // content//from www . j a va 2 s .c o m builder.setSmallIcon(R.drawable.ic_pin_white_24dp).setContentTitle(TaskFieldAdapters.TITLE.get(task)) .setOngoing(true).setShowWhen(false); // set priority for HeadsUpNotification if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { if (withHeadsUpNotification) { builder.setPriority(Notification.PRIORITY_HIGH); } else { builder.setPriority(Notification.PRIORITY_DEFAULT); } } // color is based on the priority of the task. If the task has no priority we use the primary color. Integer priority = TaskFieldAdapters.PRIORITY.get(task); if (priority != null && priority > 0) { if (priority < 5) { builder.setColor(resources.getColor(R.color.priority_red)); } if (priority == 5) { builder.setColor(resources.getColor(R.color.priority_yellow)); } if (priority > 5 && priority <= 9) { builder.setColor(resources.getColor(R.color.priority_green)); } } else { builder.setColor(resources.getColor(R.color.colorPrimary)); } // description String contentText = makePinNotificationContentText(context, task); if (contentText != null) { builder.setContentText(contentText); } // ticker text if (withTickerText) { builder.setTicker( context.getString(R.string.notification_task_pin_ticker, (TaskFieldAdapters.TITLE.get(task)))); } // click action Intent resultIntent = new Intent(Intent.ACTION_VIEW); resultIntent.setData(task.getUri()); resultIntent.setPackage(context.getPackageName()); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(resultPendingIntent); // complete action Boolean closed = TaskFieldAdapters.IS_CLOSED.get(task); if (closed == null || !closed) { Time dueTime = TaskFieldAdapters.DUE.get(task); long dueTimestamp = dueTime == null ? 0 : dueTime.toMillis(true); NotificationAction completeAction = new NotificationAction(NotificationUpdaterService.ACTION_COMPLETE, R.string.notification_action_completed, TaskFieldAdapters.TASK_ID.get(task), task.getUri(), dueTimestamp); builder.addAction(NotificationUpdaterService.getCompleteAction(context, NotificationActionUtils.getNotificationActionPendingIntent(context, completeAction))); } // unpin action builder.addAction(NotificationUpdaterService.getUnpinAction(context, TaskFieldAdapters.TASK_ID.get(task), task.getUri())); // sound if (withSound) { builder.setDefaults(Notification.DEFAULT_ALL); } else { builder.setDefaults(Notification.DEFAULT_LIGHTS); } return builder.build(); }
From source file:com.freeme.filemanager.FileExplorerTabActivity.java
public void showButtonNotify() { mBuilder = new Builder(this); RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.view_custom_button); if (IsFreemeOs.isFreemeOs()) { Bitmap bitMap = getApplicationContext().getPackageManager().getIconBitmapWithThemeBg( getResources().getDrawable(R.drawable.notification_clean), getApplicationContext().getPackageName(), 0); remoteViews.setImageViewBitmap(R.id.filemanager_notification_clean, bitMap); } else {/*from w w w . j a va 2 s .c o m*/ remoteViews.setImageViewResource(R.id.filemanager_notification_clean, R.drawable.notification_clean); } remoteViews.setTextViewText(R.id.tv_custom_title, getString(R.string.fileManager)); remoteViews.setTextViewText(R.id.tv_custom_text, getString(R.string.clean_text)); Intent buttonIntent = new Intent(ACTION_BUTTON); buttonIntent.putExtra(INTENT_BUTTONID_TAG, BUTTON_CLEAN_ID); PendingIntent intent_clean = PendingIntent.getBroadcast(this, 1, buttonIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.btn_custom, intent_clean); mBuilder.setContent(remoteViews).setContentIntent(getDefalutIntent(Notification.FLAG_AUTO_CANCEL)) .setWhen(System.currentTimeMillis()).setPriority(Notification.PRIORITY_DEFAULT).setOngoing(true) .setSmallIcon(R.drawable.notification_small_clean); notify = mBuilder.build(); notify.flags = Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify(200, notify); }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java
private int getPriorityOfMessage(MFPInternalPushMessage message) { String priorityFromServer = message.getPriority(); MFPPushNotificationOptions options = MFPPush.getInstance().getNotificationOptions(); int priorityPreSetValue = 0; if (options != null && options.getPriority() != null) { priorityPreSetValue = options.getPriority().getValue(); }//from ww w .j a va 2 s . co m if (priorityFromServer != null) { if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_MAX)) { return Notification.PRIORITY_MAX; } else if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_MIN)) { return Notification.PRIORITY_MIN; } else if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_HIGH)) { return Notification.PRIORITY_HIGH; } else if (priorityFromServer.equalsIgnoreCase(MFPPushConstants.PRIORITY_LOW)) { return Notification.PRIORITY_LOW; } } else if (priorityPreSetValue != 0) { return priorityPreSetValue; } return Notification.PRIORITY_DEFAULT; }
From source file:com.android.mms.transaction.MessagingNotification.java
public static void blockingUpdateNewIccMessageIndicator(Context context, String address, String message, int subId, long timeMillis) { final Notification.Builder noti = new Notification.Builder(context).setWhen(timeMillis); Contact contact = Contact.get(address, false); NotificationInfo info = getNewIccMessageNotificationInfo(context, true /* isSms */, address, message, null /* subject */, subId, timeMillis, null /* attachmentBitmap */, contact, WorkingMessage.TEXT); noti.setSmallIcon(R.drawable.stat_notify_sms); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context); // Update the notification. PendingIntent pendingIntent;/* www . j a va2 s. c om*/ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { pendingIntent = PendingIntent.getActivity(context, 0, info.mClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); } else { // Use requestCode to avoid updating all intents of previous notifications pendingIntent = PendingIntent.getActivity(context, ICC_NOTIFICATION_ID_BASE + subId, info.mClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); } String title = info.mTitle; noti.setContentTitle(title).setContentIntent(pendingIntent) //taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)) .setCategory(Notification.CATEGORY_MESSAGE).setPriority(Notification.PRIORITY_DEFAULT); int defaults = 0; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); boolean vibrate = false; if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE)) { // The most recent change to the vibrate preference is to store a boolean // value in NOTIFICATION_VIBRATE. If prefs contain that preference, use that // first. vibrate = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false); } else if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN)) { // This is to support the pre-JellyBean MR1.1 version of vibrate preferences // when vibrate was a tri-state setting. As soon as the user opens the Messaging // app's settings, it will migrate this setting from NOTIFICATION_VIBRATE_WHEN // to the boolean value stored in NOTIFICATION_VIBRATE. String vibrateWhen = sp.getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null); vibrate = "always".equals(vibrateWhen); } if (vibrate) { defaults |= Notification.DEFAULT_VIBRATE; } String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null); noti.setSound(TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr)); Log.d(TAG, "blockingUpdateNewIccMessageIndicator: adding sound to the notification"); defaults |= Notification.DEFAULT_LIGHTS; noti.setDefaults(defaults); // set up delete intent noti.setDeleteIntent(PendingIntent.getBroadcast(context, 0, sNotificationOnDeleteIntent, 0)); final Notification notification; // This sets the text for the collapsed form: noti.setContentText(info.formatBigMessage(context)); if (info.mAttachmentBitmap != null) { // The message has a picture, show that notification = new Notification.BigPictureStyle(noti).bigPicture(info.mAttachmentBitmap) // This sets the text for the expanded picture form: .setSummaryText(info.formatPictureMessage(context)).build(); } else { // Show a single notification -- big style with the text of the whole message notification = new Notification.BigTextStyle(noti).bigText(info.formatBigMessage(context)).build(); } notifyUserIfFullScreen(context, title); nm.notify(ICC_NOTIFICATION_ID_BASE + subId, notification); }