List of usage examples for android.app Notification DEFAULT_LIGHTS
int DEFAULT_LIGHTS
To view the source code for android.app Notification DEFAULT_LIGHTS.
Click Source Link
From source file:com.stoneapp.ourvlemoodle2.tasks.DiscussionSync.java
public void addNotification(MoodleDiscussion discussion) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ourvle_iconsmall).setContentTitle("New Topic") .setContentText(Html.fromHtml(discussion.getName()).toString().trim()); //creates an explicit intent for an activity in your app Intent resultIntent = new Intent(context, PostActivity.class); resultIntent.putExtra("discussionid", discussion.getDiscussionid() + ""); resultIntent.putExtra("discussionname", discussion.getName()); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(PostActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); Notification notification = mBuilder.build(); notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_SOUND; //notification.defaults |= Notification.DEFAULT_VIBRATE; NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(discussion.getDiscussionid(), notification); }
From source file:im.neon.util.NotificationUtils.java
/** * Build a pending call notification// w w w .j av a 2 s .co m * @param context the context. * @param roomName the room name in which the call is pending. * @param roomId the room Id * @param matrixId the matrix id * @param callId the call id. * @return the call notification. */ public static Notification buildPendingCallNotification(Context context, String roomName, String roomId, String matrixId, String callId) { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setWhen(System.currentTimeMillis()); builder.setContentTitle(roomName); builder.setContentText(context.getString(R.string.call_in_progress)); builder.setSmallIcon(R.drawable.incoming_call_notification_transparent); // Build the pending intent for when the notification is clicked Intent roomIntent = new Intent(context, VectorRoomActivity.class); roomIntent.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId); roomIntent.putExtra(VectorRoomActivity.EXTRA_MATRIX_ID, matrixId); roomIntent.putExtra(VectorRoomActivity.EXTRA_START_CALL_ID, callId); // Recreate the back stack TaskStackBuilder stackBuilder = TaskStackBuilder.create(context).addParentStack(VectorRoomActivity.class) .addNextIntent(roomIntent); // android 4.3 issue // use a generator for the private requestCode. // When using 0, the intent is not created/launched when the user taps on the notification. // PendingIntent pendingIntent = stackBuilder.getPendingIntent((new Random()).nextInt(1000), PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); Notification n = builder.build(); n.flags |= Notification.FLAG_SHOW_LIGHTS; n.defaults |= Notification.DEFAULT_LIGHTS; return n; }
From source file:com.rossier.shclechelles.service.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww . j av a 2 s. c om */ private void sendNotification(String from, String message) { Gson gson = new GsonBuilder().create(); String messageUTF8 = ""; try { messageUTF8 = new String(message.getBytes(), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.i("MyGCMListenerService", message); Log.i("MyGCMListenerService", messageUTF8); if (messageUTF8 == "") return; MatchNotification match = gson.fromJson(messageUTF8, MatchNotification.class); Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); int icon = R.drawable.ic_launcher_shc; long when = System.currentTimeMillis(); // Notification notification = new Notification(icon, "Nouveaux rsultats", when); Notification notification = new Notification.Builder(this.getBaseContext()) .setContentText("Nouveaux rsultats").setSmallIcon(icon).setWhen(when).build(); NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.match_notif_layout); contentView.setTextViewText(R.id.notif_team_home, match.getTeam_home()); contentView.setTextViewText(R.id.notif_team_away, match.getTeam_away()); contentView.setTextViewText(R.id.notif_result_home, match.getResult_home() + ""); contentView.setTextViewText(R.id.notif_result_away, match.getResult_away() + ""); contentView.setTextViewText(R.id.notif_ligue, match.getLigue()); contentView.setImageViewResource(R.id.notif_team_loc_logo, Utils.getLogo(match.getTeam_home())); contentView.setImageViewResource(R.id.notif_team_away_logo, Utils.getLogo(match.getTeam_away())); notification.contentView = contentView; Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.contentIntent = contentIntent; //notification.flags |= Notification.FLAG_ONGOING_EVENT; //Do not clear the notification notification.defaults |= Notification.DEFAULT_LIGHTS; // LED notification.defaults |= Notification.DEFAULT_VIBRATE; //Vibration notification.defaults |= Notification.DEFAULT_SOUND; // Sound //get topics name String[] topic = from.split("/"); mNotificationManager.notify(topic[2].hashCode(), notification); }
From source file:com.money.manager.ex.notifications.RecurringTransactionNotifications.java
private void showNotification(Cursor cursor) { CurrencyService currencyService = new CurrencyService(mContext); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); while (cursor.moveToNext()) { String payeeName = cursor.getString(cursor.getColumnIndex(QueryBillDeposits.PAYEENAME)); // check if payee name is null, then put toAccountName if (TextUtils.isEmpty(payeeName)) payeeName = cursor.getString(cursor.getColumnIndex(QueryBillDeposits.TOACCOUNTNAME)); // compose text String line = cursor.getString(cursor.getColumnIndex(QueryBillDeposits.USERNEXTOCCURRENCEDATE)) + " " + payeeName + ": <b>" + currencyService.getCurrencyFormatted( cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID)), MoneyFactory//w w w. ja v a2s. co m .fromDouble(cursor.getDouble(cursor.getColumnIndex(QueryBillDeposits.AMOUNT)))) + "</b>"; // add line inboxStyle.addLine(Html.fromHtml("<small>" + line + "</small>")); } NotificationManager notificationManager = (NotificationManager) getContext() .getSystemService(Context.NOTIFICATION_SERVICE); // create pending intent Intent intent = new Intent(getContext(), RecurringTransactionListActivity.class); // set launch from notification // check pin code intent.putExtra(RecurringTransactionListActivity.INTENT_EXTRA_LAUNCH_NOTIFICATION, true); PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), 0, intent, 0); // todo: Actions // Intent skipIntent = new Intent(intent); // //skipIntent.setAction(Intent.) // PendingIntent skipPending = PendingIntent.getActivity(getContext(), 0, skipIntent, 0); // Intent enterIntent = new Intent(getContext(), RecurringTransactionEditActivity.class); // PendingIntent enterPending = PendingIntent.getActivity(getContext(), 0, enterIntent, 0); // create notification try { Notification notification = new NotificationCompat.Builder(getContext()).setAutoCancel(true) .setContentIntent(pendingIntent).setContentTitle(mContext.getString(R.string.application_name)) .setContentText(mContext.getString(R.string.notification_repeating_transaction_expired)) .setSubText(mContext.getString(R.string.notification_click_to_check_repeating_transaction)) .setSmallIcon(R.drawable.ic_stat_notification) .setTicker(mContext.getString(R.string.notification_repeating_transaction_expired)) .setDefaults( Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS) .setNumber(cursor.getCount()).setStyle(inboxStyle) .setColor(mContext.getResources().getColor(R.color.md_primary)) // .addAction(R.drawable.ic_action_content_clear_dark, getContext().getString(R.string.skip), skipPending) // .addAction(R.drawable.ic_action_done_dark, getContext().getString(R.string.enter), enterPending) .build(); // notify notificationManager.cancel(ID_NOTIFICATION); notificationManager.notify(ID_NOTIFICATION, notification); } catch (Exception e) { Timber.e(e, "showing notification for recurring transaction"); } }
From source file:me.acristoffers.tracker.AlarmReceiver.java
@Override public void statusUpdated(final Package pkg) { final String code = pkg.getCod(); final int count = pkg.getSteps().size(); if (countSteps.get(code) < count) { pkg.save();//from w w w . ja v a2 s . co m final NotificationManager notificationManager = (NotificationManager) context.get() .getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { final String title = context.get().getString(R.string.notification_package_updated_title, pkg.getName()); final String message = context.get().getString(R.string.notification_package_updated_body, pkg.getName()); final Intent intent = new Intent(context.get(), PackageDetailsActivity.class); intent.putExtra(PackageDetailsActivity.PACKAGE_CODE, code); final PendingIntent pendingIntent = PendingIntent.getActivity(context.get(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); final Bitmap icon = BitmapFactory.decodeResource(context.get().getResources(), R.mipmap.ic_launcher); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context.get()); builder.setTicker(title).setContentTitle(title).setContentText(message) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setContentIntent(pendingIntent).setSmallIcon(R.mipmap.ic_launcher).setLargeIcon(icon) .setWhen(System.currentTimeMillis()).setAutoCancel(true); final Notification notification = builder.build(); final NotificationManager nm = (NotificationManager) context.get() .getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(pkg.getId(), notification); } } }
From source file:vn.easycare.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from ww w . j a v a 2 s . c o m private void generateNotification(Context context, String message) { int icon = R.drawable.ic_launcher; long when = 0;//System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, NotificationReceivingActivity.class); // set intent so it does not start a new activity // notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent intent = PendingIntent.getActivity(context, (int) when, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; notification.flags |= Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; notificationManager.notify((int) when, notification); }
From source file:br.com.recidev.gamethis.util.GcmIntentService.java
private void sendNotification(String msg, String tipoNotificacao, Bundle extras) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = null;//from w w w. ja va2 s . c o m if (tipoNotificacao.equals("Novo Usuario")) { Usuario usuario = new Usuario(); usuario.setNome(extras.getString("nome")); usuario.setEmail(extras.getString("email")); usuario.setSenha(extras.getString("senha")); usuario.setAvatar(Integer.parseInt(extras.getString("avatar"))); usuario.setNome(extras.getString("syncStatus")); usuario.setGcm_id(extras.getString("gcm_id")); contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, HomeActivity.class), 0); } if (tipoNotificacao.equals("Novo Jogo")) { //TODO Ajustar depois o encaminhamento para meus jogos contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, HomeActivity.class), 0); } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.game_this_2).setContentTitle("GameThis") .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(contentIntent); Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.toasty); mBuilder.setSound(sound); int defaults = 0; defaults = defaults | Notification.DEFAULT_LIGHTS; defaults = defaults | Notification.DEFAULT_VIBRATE; //defaults = defaults | Notification.DEFAULT_SOUND; mBuilder.setDefaults(defaults); mBuilder.setAutoCancel(true); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:uk.org.rivernile.edinburghbustracker.android.alerts.ProximityAlertReceiver.java
/** * {@inheritDoc}/*from w w w. j a v a2 s . co m*/ */ @Override public void onReceive(final Context context, final Intent intent) { final SettingsDatabase db = SettingsDatabase.getInstance(context); final String stopCode = intent.getStringExtra(ARG_STOPCODE); // Make sure the alert is still active to remain relevant. if (!db.isActiveProximityAlert(stopCode)) return; final String stopName = BusStopDatabase.getInstance(context).getNameForBusStop(stopCode); final NotificationManager notMan = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); final LocationManager locMan = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); // Delete the alert from the database. db.deleteAllAlertsOfType(SettingsDatabase.ALERTS_TYPE_PROXIMITY); // Make sure the LocationManager no longer checks for this proximity. final PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); locMan.removeProximityAlert(pi); final String title = context.getString(R.string.proxreceiver_notification_title, stopName); final String summary = context.getString(R.string.proxreceiver_notification_summary, intent.getIntExtra(ARG_DISTANCE, 0), stopName); final String ticker = context.getString(R.string.proxreceiver_notification_ticker, stopName); final SharedPreferences sp = context.getSharedPreferences(PreferencesActivity.PREF_FILE, 0); // Create the notification. final NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context); notifBuilder.setAutoCancel(true); notifBuilder.setSmallIcon(R.drawable.ic_status_bus); notifBuilder.setTicker(ticker); notifBuilder.setContentTitle(title); notifBuilder.setContentText(summary); // Support for Jelly Bean notifications. notifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(summary)); final Intent launchIntent; if (GenericUtils.isGoogleMapsAvailable(context)) { // The Intent which launches the bus stop map at the selected stop. launchIntent = new Intent(context, BusStopMapActivity.class); launchIntent.putExtra(BusStopMapActivity.ARG_STOPCODE, stopCode); } else { launchIntent = new Intent(context, BusStopDetailsActivity.class); launchIntent.putExtra(BusStopDetailsActivity.ARG_STOPCODE, stopCode); } notifBuilder .setContentIntent(PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_ONE_SHOT)); final Notification n = notifBuilder.build(); if (sp.getBoolean(PreferencesActivity.PREF_ALERT_SOUND, true)) n.defaults |= Notification.DEFAULT_SOUND; if (sp.getBoolean(PreferencesActivity.PREF_ALERT_VIBRATE, true)) n.defaults |= Notification.DEFAULT_VIBRATE; if (sp.getBoolean(PreferencesActivity.PREF_ALERT_LED, true)) { n.defaults |= Notification.DEFAULT_LIGHTS; n.flags |= Notification.FLAG_SHOW_LIGHTS; } // Send the notification to the UI. notMan.notify(ALERT_ID, n); }
From source file:com.anysoftkeyboard.ChewbaccaUncaughtExceptionHandler.java
public void uncaughtException(Thread thread, Throwable ex) { Log.e(TAG, "Caught an unhandled exception!!!", ex); boolean ignore = false; // https://github.com/AnySoftKeyboard/AnySoftKeyboard/issues/15 //https://github.com/AnySoftKeyboard/AnySoftKeyboard/issues/433 String stackTrace = Log.getStackTrace(ex); if (ex instanceof NullPointerException) { if (stackTrace.contains( "android.inputmethodservice.IInputMethodSessionWrapper.executeMessage(IInputMethodSessionWrapper.java") || stackTrace.contains(//from w w w .j a va 2 s . c o m "android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java")) { Log.w(TAG, "An OS bug has been adverted. Move along, there is nothing to see here."); ignore = true; } } else if (ex instanceof java.util.concurrent.TimeoutException) { if (stackTrace.contains(".finalize")) { Log.w(TAG, "An OS bug has been adverted. Move along, there is nothing to see here."); ignore = true; } } if (!ignore && AnyApplication.getConfig().useChewbaccaNotifications()) { String appName = DeveloperUtils.getAppDetails(mApp); final CharSequence utcTimeDate = DateFormat.format("kk:mm:ss dd.MM.yyyy", new Date()); final String newline = DeveloperUtils.NEW_LINE; String logText = "Hi. It seems that we have crashed.... Here are some details:" + newline + "****** UTC Time: " + utcTimeDate + newline + "****** Application name: " + appName + newline + "******************************" + newline + "****** Exception type: " + ex.getClass().getName() + newline + "****** Exception message: " + ex.getMessage() + newline + "****** Trace trace:" + newline + stackTrace + newline; logText += "******************************" + newline + "****** Device information:" + newline + DeveloperUtils.getSysInfo(mApp); if (ex instanceof OutOfMemoryError || (ex.getCause() != null && ex.getCause() instanceof OutOfMemoryError)) { logText += "******************************\n" + "****** Memory:" + newline + getMemory(); } logText += "******************************" + newline + "****** Log-Cat:" + newline + Log.getAllLogLines(); String crashType = ex.getClass().getSimpleName() + ": " + ex.getMessage(); Intent notificationIntent = new Intent(mApp, SendBugReportUiActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final Parcelable reportDetailsExtra = new SendBugReportUiActivity.BugReportDetails(ex, logText); notificationIntent.putExtra(SendBugReportUiActivity.EXTRA_KEY_BugReportDetails, reportDetailsExtra); PendingIntent contentIntent = PendingIntent.getActivity(mApp, 0, notificationIntent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(mApp); builder.setSmallIcon( Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? R.drawable.notification_error_icon : R.drawable.ic_notification_error) .setColor(ContextCompat.getColor(mApp, R.color.notification_background_error)) .setTicker(mApp.getText(R.string.ime_crashed_ticker)) .setContentTitle(mApp.getText(R.string.ime_name)) .setContentText(mApp.getText(R.string.ime_crashed_sub_text)) .setSubText(BuildConfig.TESTING_BUILD ? crashType : null/*not showing the type of crash in RELEASE mode*/) .setWhen(System.currentTimeMillis()).setContentIntent(contentIntent).setAutoCancel(true) .setOnlyAlertOnce(true).setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); // notifying NotificationManager notificationManager = (NotificationManager) mApp .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(R.id.notification_icon_app_error, builder.build()); } // and sending to the OS if (!ignore && mOsDefaultHandler != null) { Log.i(TAG, "Sending the exception to OS exception handler..."); mOsDefaultHandler.uncaughtException(thread, ex); } Thread.yield(); //halting the process. No need to continue now. I'm a dead duck. System.exit(0); }
From source file:ro.softronic.mihai.ro.papamia.Services.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*from ww w . j a va 2s . com*/ private void sendNotification(NotificationData notificationData) { // Intent intent = new Intent(this, CategoriiActivity.class); Intent intent = new Intent().setClass(this, CategoriiActivity.class); // intent.putExtra(NotificationData.TEXT, notificationData.getTextMessage()); intent.putExtra("flag", 1); // intent.setAction(Intent.ACTION_SEARCH); //// intent.addCategory(Intent.CATEGORY_LAUNCHER); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // intent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder notificationBuilder = null; try { notificationBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.ic_launcher) // .setContentTitle(URLDecoder.decode("aslkas", "UTF-8")) .setContentText(URLDecoder.decode("alskalsk", "UTF-8")) // .setAutoCancel(true) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentIntent(pendingIntent).addAction(R.drawable.arrows_right_icon, "Call", pendingIntent); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (notificationBuilder != null) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification noti = notificationBuilder.build(); noti.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, noti); } else { Log.d(TAG, "No foi possvel criar objeto notificationBuilder"); } }