List of usage examples for android.app Notification CATEGORY_ERROR
String CATEGORY_ERROR
To view the source code for android.app Notification CATEGORY_ERROR.
Click Source Link
From source file:com.lambdasoup.quickfit.persist.FitApiFailureResolutionService.java
private void handleErrorInBackground(ConnectionResult connectionResult, int startId) { if (!connectionResult.hasResolution()) { // Show the localized error notification GoogleApiAvailability.getInstance().showErrorNotification(this, connectionResult.getErrorCode()); return;/*w ww . j ava 2 s . c om*/ } // The failure has a resolution. Resolve it. // Called typically when the app is not yet authorized, and an // authorization dialog is displayed to the user. Intent resultIntent = new Intent(this, WorkoutListActivity.class); resultIntent.putExtra(WorkoutListActivity.EXTRA_PLAY_API_CONNECT_RESULT, connectionResult); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(WorkoutListActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setContentTitle(getResources().getString(R.string.permission_needed_play_service_title)) .setContentText(getResources().getString(R.string.permission_needed_play_service)) .setSmallIcon(R.drawable.common_ic_googleplayservices).setContentIntent(resultPendingIntent) .setAutoCancel(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { notificationBuilder.setCategory(Notification.CATEGORY_ERROR); } ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)) .notify(Constants.NOTIFICATION_PLAY_INTERACTION, notificationBuilder.build()); stopSelfResult(startId); }
From source file:com.stanleyidesis.quotograph.api.controller.LWQNotificationControllerImpl.java
@Override public void postWallpaperGenerationFailureNotification() { // Two actions: Network Settings & Try Again LWQApplication context = LWQApplication.get(); // Establish basic options NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context); notificationBuilder.setAutoCancel(true); notificationBuilder.setCategory(/*from w ww. ja v a 2 s. c o m*/ Build.VERSION.SDK_INT > 21 ? Notification.CATEGORY_ERROR : Notification.CATEGORY_SERVICE); notificationBuilder.setColor(LWQApplication.get().getResources().getColor(R.color.palette_A100)); notificationBuilder.setContentInfo(context.getString(R.string.app_name)); notificationBuilder.setContentTitle(context.getString(R.string.notification_generation_failure_title)); notificationBuilder.setContentText(context.getString(R.string.notification_generation_failure_content)); notificationBuilder.setLights(LWQApplication.get().getResources().getColor(R.color.palette_A100), 500, 500); notificationBuilder.setTicker(context.getString(R.string.notification_generation_failure_ticker)); notificationBuilder.setOngoing(false); notificationBuilder.setShowWhen(true); notificationBuilder.setLocalOnly(true); notificationBuilder.setPriority(NotificationCompat.PRIORITY_MIN); notificationBuilder.setSmallIcon(android.R.drawable.stat_notify_error); notificationBuilder.setWhen(System.currentTimeMillis()); // Create BigTextStyle NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); bigTextStyle.setBigContentTitle(context.getString(R.string.notification_generation_failure_title)); bigTextStyle.bigText(context.getString(R.string.notification_generation_failure_content)); notificationBuilder.setStyle(bigTextStyle); // Add Settings Action Intent settingsIntent = new Intent(Settings.ACTION_WIRELESS_SETTINGS); final PendingIntent settingsBroadcast = PendingIntent.getActivity(context, uniqueRequestCode++, settingsIntent, 0); final NotificationCompat.Action settingsAction = new NotificationCompat.Action.Builder( R.mipmap.ic_settings_white, context.getString(R.string.notification_generation_failure_action_settings), settingsBroadcast) .build(); notificationBuilder.addAction(settingsAction); // Add Skip Action Intent skipIntent = new Intent(context, LWQReceiver.class); skipIntent.setAction(context.getString(R.string.action_change_wallpaper)); skipIntent.setData(Uri.parse(AnalyticsUtils.URI_CHANGE_SOURCE_NOTIFICATION)); final PendingIntent skipBroadcast = PendingIntent.getBroadcast(context, uniqueRequestCode++, skipIntent, 0); final NotificationCompat.Action skipAction = new NotificationCompat.Action.Builder( R.mipmap.ic_refresh_white_36dp, context.getString(R.string.notification_generation_failure_action_try_again), skipBroadcast) .build(); notificationBuilder.addAction(skipAction); // Set Skip as main action notificationBuilder.setContentIntent(skipBroadcast); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIF_ID_GEN_FAILURE, notificationBuilder.build()); }
From source file:com.stanleyidesis.quotograph.api.controller.LWQNotificationControllerImpl.java
@Override public void postWallpaperSaveFailureNotification() { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(LWQApplication.get()); notificationBuilder.setAutoCancel(true); notificationBuilder.setCategory(Notification.CATEGORY_ERROR); notificationBuilder.setColor(LWQApplication.get().getResources().getColor(R.color.palette_A100)); notificationBuilder/*w ww . j av a 2 s . co m*/ .setContentTitle(LWQApplication.get().getString(R.string.notification_title_save_failed)); notificationBuilder .setContentText(LWQApplication.get().getString(R.string.notification_content_save_failed)); notificationBuilder.setLights(LWQApplication.get().getResources().getColor(R.color.palette_A100), 500, 500); notificationBuilder.setOngoing(false); notificationBuilder.setShowWhen(false); notificationBuilder.setSmallIcon(R.mipmap.ic_stat); notificationBuilder .setTicker(String.format(LWQApplication.get().getString(R.string.notification_title_save_failed))); notificationBuilder.setWhen(System.currentTimeMillis()); Intent saveToDiskIntent = new Intent(LWQApplication.get(), LWQSaveWallpaperActivity.class); saveToDiskIntent.setData(Uri.parse(AnalyticsUtils.URI_SAVE_SOURCE_NOTIFICATION)); final PendingIntent saveToDiskActivity = PendingIntent.getActivity(LWQApplication.get(), uniqueRequestCode++, saveToDiskIntent, 0); notificationBuilder.setContentIntent(saveToDiskActivity); NotificationManager notificationManager = (NotificationManager) LWQApplication.get() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIF_ID_SAVE_FAILURE, notificationBuilder.build()); }