本文整理汇总了Java中android.app.NotificationManager.IMPORTANCE_HIGH属性的典型用法代码示例。如果您正苦于以下问题:Java NotificationManager.IMPORTANCE_HIGH属性的具体用法?Java NotificationManager.IMPORTANCE_HIGH怎么用?Java NotificationManager.IMPORTANCE_HIGH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.NotificationManager
的用法示例。
在下文中一共展示了NotificationManager.IMPORTANCE_HIGH属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initNotificationManager
private void initNotificationManager() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
final Stopwatch watch = Stopwatch.createStarted();
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
final NotificationChannel received = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_RECEIVED,
getString(R.string.notification_channel_received_name), NotificationManager.IMPORTANCE_DEFAULT);
received.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.coins_received),
new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setLegacyStreamType(AudioManager.STREAM_NOTIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT).build());
nm.createNotificationChannel(received);
final NotificationChannel ongoing = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_ONGOING,
getString(R.string.notification_channel_ongoing_name), NotificationManager.IMPORTANCE_LOW);
nm.createNotificationChannel(ongoing);
final NotificationChannel important = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_IMPORTANT,
getString(R.string.notification_channel_important_name), NotificationManager.IMPORTANCE_HIGH);
nm.createNotificationChannel(important);
log.info("created notification channels, took {}", watch);
}
}
示例2: createNotificationChannel
@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel(){
String channelId = "VBrowserNotification";
String channelName = "前台下载通知";
NotificationChannel chan = new NotificationChannel(channelId,
channelName, NotificationManager.IMPORTANCE_HIGH);
chan.setLightColor(Color.BLUE);
chan.setImportance(NotificationManager.IMPORTANCE_NONE);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager service = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
service.createNotificationChannel(chan);
return channelId;
}
示例3: NotificationHelper
/**
* Registers notification channels, which can be used later by individual notifications.
*
* @param ctx The application context
*/
public NotificationHelper(Context ctx) {
super(ctx);
NotificationChannel chan1 = new NotificationChannel(PRIMARY_CHANNEL,
getString(R.string.noti_channel_default), NotificationManager.IMPORTANCE_DEFAULT);
chan1.setLightColor(Color.GREEN);
chan1.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
getManager().createNotificationChannel(chan1);
NotificationChannel chan2 = new NotificationChannel(SECONDARY_CHANNEL,
getString(R.string.noti_channel_second), NotificationManager.IMPORTANCE_HIGH);
chan2.setLightColor(Color.BLUE);
chan2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
getManager().createNotificationChannel(chan2);
}
示例4: getNotificationChannelID
private String getNotificationChannelID() {
final String channelID = "GoalieChannelID";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.app_name);
String description = getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = new NotificationChannel(channelID, name, importance);
mChannel.setDescription(description);
mChannel.enableLights(true);
mChannel.enableVibration(true);
mNotificationManager.createNotificationChannel(mChannel);
}
return channelID;
}
示例5: createNotificationChannels
public static void createNotificationChannels(Context context) {
if(android.os.Build.VERSION.SDK_INT >= 26) {
NotificationChannel diaryChannel = new NotificationChannel(
NOTIFICATION_CHANNEL_ID_DIARY,
context.getString(R.string.diary_reminder_notification_channel_name),
NotificationManager.IMPORTANCE_HIGH);
diaryChannel.setDescription(context.getString(R.string.diary_reminder_notification_channel_description));
NotificationChannel playerChannel = new NotificationChannel(
NOTIFICATION_CHANNEL_ID_PLAYER,
context.getString(R.string.player_notification_channel_name),
NotificationManager.IMPORTANCE_DEFAULT);
playerChannel.setDescription(context.getString(R.string.player_notification_channel_description));
// Create channels
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(diaryChannel);
notificationManager.createNotificationChannel(playerChannel);
}
}
示例6: createNotificationChannel
private void createNotificationChannel() {
NotificationManager mNotificationManager =
(NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.imagepipeline_notification_channel_name);
int importance =
NotificationManager
.IMPORTANCE_HIGH; // high importance shows the notification on the user screen.
NotificationChannel mChannel =
new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
mNotificationManager.createNotificationChannel(mChannel);
}
示例7: showNotification
private void showNotification() {
final Intent notificationIntent = new Intent(mContext, EditContactActivity.class);
String CHANNEL_ID = "lead-management-ch";
notificationIntent.putExtra(
EditContactActivity.INTENT_EXTRA_CONTACT_NUM, number);
final PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Builder notification = new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_call_black_24dp)
.setContentTitle("Call in Progress")
.setTicker("Lead Management")
.setContentIntent(contentIntent)
.setContentText("Number: " + number)
.setChannelId(CHANNEL_ID);
final NotificationManager manager =
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (manager != null) {
manager.cancel(ID);
// check build version
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "Lead-Management-Channel";
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
manager.createNotificationChannel(mChannel);
}
manager.notify(ID, notification.build());
}
}
示例8: createChannel
private void createChannel(String id, String name, String description) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(id, name,
NotificationManager.IMPORTANCE_HIGH);
mChannel.setDescription(description);
mChannel.enableLights(true);
mChannel.setLightColor(Color.RED);
mChannel.enableVibration(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 100});
notificationManager.createNotificationChannel(mChannel);
}
}
示例9: createChannels
public void createChannels(){
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel mChannelOne = new NotificationChannel(CHANNEL_GENERAL_ID, CHANNEL_GENERAL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
mChannelOne.setDescription(CHANNEL_GENERAL_ABOUT);
mChannelOne.enableLights(false);
mChannelOne.setLightColor(getColor(R.color.colorPrimary));
mChannelOne.setShowBadge(true);
mChannelOne.enableVibration(false);
mChannelOne.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
getNotificationManager().createNotificationChannel(mChannelOne);
NotificationChannel mChannelTwo = new NotificationChannel(CHANNEL_BUG_TRACKER_ID, CHANNEL_BUG_TRACKER_NAME, NotificationManager.IMPORTANCE_HIGH);
mChannelTwo.setDescription(CHANNEL_BUG_TRACKER_ABOUT);
mChannelTwo.enableLights(true);
mChannelTwo.enableVibration(true);
mChannelTwo.setLightColor(getColor(R.color.colorPrimary));
mChannelTwo.setShowBadge(true);
getNotificationManager().createNotificationChannel(mChannelTwo);
NotificationChannel mChannelThree = new NotificationChannel(CHANNEL_SERVICE_ID, CHANNEL_SERVICE_NAME, NotificationManager.IMPORTANCE_MIN);
mChannelThree.setDescription(CHANNEL_SERVICE_ABOUT);
mChannelThree.enableLights(false);
mChannelThree.enableVibration(false);
mChannelThree.setLightColor(getColor(R.color.colorPrimary));
mChannelThree.setShowBadge(false);
getNotificationManager().createNotificationChannel(mChannelThree);
}
}
示例10: remindUserBecauseCharging
public static void remindUserBecauseCharging(Context context) {
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(
WATER_REMINDER_NOTIFICATION_CHANNEL_ID,
context.getString(R.string.main_notification_channel_name),
NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(mChannel);
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context,WATER_REMINDER_NOTIFICATION_CHANNEL_ID)
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
.setSmallIcon(R.drawable.ic_drink_notification)
.setLargeIcon(largeIcon(context))
.setContentTitle(context.getString(R.string.charging_reminder_notification_title))
.setContentText(context.getString(R.string.charging_reminder_notification_body))
.setStyle(new NotificationCompat.BigTextStyle().bigText(
context.getString(R.string.charging_reminder_notification_body)))
.setDefaults(Notification.DEFAULT_VIBRATE)
.setContentIntent(contentIntent(context))
// COMPLETED (17) Add the two new actions using the addAction method and your helper methods
.addAction(drinkWaterAction(context))
.addAction(ignoreReminderAction(context))
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
notificationBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
}
notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
}
示例11: remindUserBecauseCharging
public static void remindUserBecauseCharging(Context context) {
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(
WATER_REMINDER_NOTIFICATION_CHANNEL_ID,
context.getString(R.string.main_notification_channel_name),
NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(mChannel);
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context,WATER_REMINDER_NOTIFICATION_CHANNEL_ID)
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
.setSmallIcon(R.drawable.ic_drink_notification)
.setLargeIcon(largeIcon(context))
.setContentTitle(context.getString(R.string.charging_reminder_notification_title))
.setContentText(context.getString(R.string.charging_reminder_notification_body))
.setStyle(new NotificationCompat.BigTextStyle().bigText(
context.getString(R.string.charging_reminder_notification_body)))
.setDefaults(Notification.DEFAULT_VIBRATE)
.setContentIntent(contentIntent(context))
.addAction(drinkWaterAction(context))
.addAction(ignoreReminderAction(context))
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
notificationBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
}
notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
}
示例12: createChannel
@TargetApi(26)
private void createChannel() {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME,
NotificationManager.IMPORTANCE_HIGH);
notificationChannel.enableLights(true);
notificationChannel.enableVibration(true);
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
getManager().createNotificationChannel(notificationChannel);
}
示例13: onCreate
@Override
public void onCreate() {
super.onCreate();
sInstance = this;
Fabric.with(this, new Crashlytics());
StringsManager.initialize();
TwitterConfig config = new TwitterConfig.Builder(this)
.logger(new DefaultLogger(Log.DEBUG))
.twitterAuthConfig(new TwitterAuthConfig(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET))
.debug(true)
.build();
Twitter.initialize(config);
//Create Notification channel in Android O
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (notificationManager != null) {
NotificationChannel mChannel = new NotificationChannel("referendum",
StringsManager.getString("notification_channel_name"), NotificationManager.IMPORTANCE_HIGH);
mChannel.setDescription(StringsManager.getString("notification_channel_description"));
mChannel.enableLights(true);
mChannel.setLightColor(Color.RED);
notificationManager.createNotificationChannel(mChannel);
}
}
}
示例14: createNotificationChannel
private void createNotificationChannel() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel genChannel = new NotificationChannel(GENERAL_CHANNEL,
getResources().getString(R.string.general_channel),
NotificationManager.IMPORTANCE_HIGH);
genChannel.setShowBadge(true);
genChannel.setLightColor(Color.BLUE);
notificationManager.createNotificationChannel(genChannel);
}
}
示例15: onCreate
/**
* Called on service creation, sends a notification
*/
@Override
public void onCreate() {
sInstance = this;
mApp = (HavenApp)getApplication();
manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
mPrefs = new PreferenceManager(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mChannel = new NotificationChannel(channelId, channelName,
NotificationManager.IMPORTANCE_HIGH);
mChannel.setDescription(channelDescription);
mChannel.setLightColor(Color.RED);
mChannel.setImportance(NotificationManager.IMPORTANCE_MIN);
manager.createNotificationChannel(mChannel);
}
startSensors();
showNotification();
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MyWakelockTag");
wakeLock.acquire();
}