use of android.app.NotificationChannel in project schedule_notifications by serralvo.
the class AlarmReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
String title = intent.getStringExtra(IntentConstants.TITLE_PARAM);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.createNotificationChannel(channel);
}
Intent actionIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
PendingIntent actionPendingIntent = PendingIntent.getActivity(context, 0, actionIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID).setSmallIcon(NotificationSingleton.getInstance().getNotificationIcon()).setContentTitle(title).setContentIntent(actionPendingIntent).setAutoCancel(true).setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
}
use of android.app.NotificationChannel in project PhoneProfilesPlus by henrichg.
the class PPApplication method createGrantPermissionNotificationChannel.
static void createGrantPermissionNotificationChannel(Context context) {
if (Build.VERSION.SDK_INT >= 26) {
// The user-visible name of the channel.
CharSequence name = context.getString(R.string.notification_channel_grant_permission);
// The user-visible description of the channel.
String description = context.getString(R.string.notification_channel_grant_permission_description);
NotificationChannel channel = new NotificationChannel(GRANT_PERMISSION_NOTIFICATION_CHANNEL, name, NotificationManager.IMPORTANCE_DEFAULT);
// Configure the notification channel.
// channel.setImportance(importance);
channel.setDescription(description);
channel.enableLights(false);
// Sets the notification light color for notifications posted to this
// channel, if the device supports this feature.
// channel.setLightColor(Color.RED);
channel.enableVibration(false);
// channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null)
notificationManager.createNotificationChannel(channel);
}
}
use of android.app.NotificationChannel in project PhoneProfilesPlus by henrichg.
the class PPApplication method createInformationNotificationChannel.
static void createInformationNotificationChannel(Context context) {
if (Build.VERSION.SDK_INT >= 26) {
// The user-visible name of the channel.
CharSequence name = context.getString(R.string.notification_channel_information);
// The user-visible description of the channel.
String description = context.getString(R.string.empty_string);
NotificationChannel channel = new NotificationChannel(INFORMATION_NOTIFICATION_CHANNEL, name, NotificationManager.IMPORTANCE_LOW);
// Configure the notification channel.
// channel.setImportance(importance);
channel.setDescription(description);
channel.enableLights(false);
// Sets the notification light color for notifications posted to this
// channel, if the device supports this feature.
// channel.setLightColor(Color.RED);
channel.enableVibration(false);
// channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null)
notificationManager.createNotificationChannel(channel);
}
}
use of android.app.NotificationChannel in project PhoneProfilesPlus by henrichg.
the class PPApplication method createProfileNotificationChannel.
// --------------------------------
// notification channels -------------------------
static void createProfileNotificationChannel(/*Profile profile, */
Context context) {
if (Build.VERSION.SDK_INT >= 26) {
// no sound
/*int importance = NotificationManager.IMPORTANCE_LOW;
if (ApplicationPreferences.notificationShowInStatusBar(context)) {
KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if (myKM != null) {
//boolean screenUnlocked = !myKM.inKeyguardRestrictedInputMode();
//boolean screenUnlocked = getScreenUnlocked(context);
boolean screenUnlocked = !myKM.isKeyguardLocked();
if ((ApplicationPreferences.notificationHideInLockScreen(context) && (!screenUnlocked)) ||
((profile != null) && profile._hideStatusBarIcon))
importance = NotificationManager.IMPORTANCE_MIN;
}
} else
importance = NotificationManager.IMPORTANCE_MIN;*/
// The user-visible name of the channel.
CharSequence name = context.getString(R.string.notification_channel_activated_profile);
// The user-visible description of the channel.
String description = context.getString(R.string.notification_channel_activated_profile_description_ppp);
NotificationChannel channel = new NotificationChannel(PROFILE_NOTIFICATION_CHANNEL, name, NotificationManager.IMPORTANCE_LOW);
// Configure the notification channel.
// channel.setImportance(importance);
channel.setDescription(description);
channel.enableLights(false);
// Sets the notification light color for notifications posted to this
// channel, if the device supports this feature.
// channel.setLightColor(Color.RED);
channel.enableVibration(false);
// channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null)
notificationManager.createNotificationChannel(channel);
}
}
use of android.app.NotificationChannel in project PhoneProfilesPlus by henrichg.
the class PPApplication method createExclamationNotificationChannel.
static void createExclamationNotificationChannel(Context context) {
if (Build.VERSION.SDK_INT >= 26) {
// The user-visible name of the channel.
CharSequence name = context.getString(R.string.notification_channel_exclamation);
// The user-visible description of the channel.
String description = context.getString(R.string.empty_string);
NotificationChannel channel = new NotificationChannel(EXCLAMATION_NOTIFICATION_CHANNEL, name, NotificationManager.IMPORTANCE_DEFAULT);
// Configure the notification channel.
// channel.setImportance(importance);
channel.setDescription(description);
channel.enableLights(false);
// Sets the notification light color for notifications posted to this
// channel, if the device supports this feature.
// channel.setLightColor(Color.RED);
channel.enableVibration(false);
// channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null)
notificationManager.createNotificationChannel(channel);
}
}
Aggregations