项目:LaunchEnr
文件:NotificationListener.java
private boolean shouldBeFilteredOut(StatusBarNotification sbn) {
Notification notification = sbn.getNotification();
if (AndroidVersion.isAtLeastOreo()) {
getCurrentRanking().getRanking(sbn.getKey(),mTempRanking);
if (!mTempRanking.canShowBadge()) {
return true;
}
if (mTempRanking.getChannel().getId().equals(NotificationChannel.DEFAULT_CHANNEL_ID)) {
// Special filtering for the default,legacy "Miscellaneous" channel.
if ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) {
return true;
}
}
}
if ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) {
return true;
}
boolean isGroupHeader = (notification.flags & Notification.FLAG_GROUP_SUMMARY) != 0;
CharSequence title = notification.extras.getCharSequence(Notification.EXTRA_TITLE);
CharSequence text = notification.extras.getCharSequence(Notification.EXTRA_TEXT);
boolean missingTitleAndText = TextUtils.isEmpty(title) && TextUtils.isEmpty(text);
return (isGroupHeader || missingTitleAndText);
}
项目:KernelAdiutor-Mod
文件:ApplyOnBootService.java
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationmanager notificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID,getString(R.string.apply_on_boot),notificationmanager.IMPORTANCE_DEFAULT);
notificationChannel.setSound(null,null);
notificationmanager.createNotificationChannel(notificationChannel);
Notification.Builder builder = new Notification.Builder(
this,CHANNEL_ID);
builder.setContentTitle(getString(R.string.apply_on_boot))
.setSmallIcon(R.mipmap.ic_launcher);
startForeground(NotificationId.APPLY_ON_BOOT,builder.build());
}
}
项目:NovaMusicPlayer
文件:Novanotificationmanager.java
private void createNotificationChannelForAndroidO() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mnotificationmanager != null) {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,"Nova Music Player",notificationmanager.IMPORTANCE_LOW);
// Configure the notification channel.
notificationChannel.setDescription("Channel of Nova Music Player");
notificationChannel.enableLights(false);
notificationChannel.setLightColor(Color.RED);
notificationChannel.setVibrationPattern(new long[]{0,1000,500,1000});
notificationChannel.setSound(null,null);
notificationChannel.enableVibration(false);
notificationChannel.setShowBadge(false);
mnotificationmanager.createNotificationChannel(notificationChannel);
}
}
项目:android-mobile-engage-sdk
文件:MessagingServiceUtilsTest.java
@Test
@SdkSuppress(minSdkVersion = O)
public void testCreateChannel_overridesPrevIoUs(){
notificationmanager manager = (notificationmanager)context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.deleteNotificationChannel("ems_me_default");
assertNull(manager.getNotificationChannel("ems_me_default"));
MessagingServiceUtils.createDefaultChannel(context,enabledOreoConfig);
NotificationChannel channel = manager.getNotificationChannel("ems_me_default");
assertNotNull(channel);
OreoConfig updatedConfig = new OreoConfig(true,"updatedname","updatedDescription");
MessagingServiceUtils.createDefaultChannel(context,updatedConfig);
NotificationChannel updatedChannel = manager.getNotificationChannel("ems_me_default");
assertEquals(updatedConfig.getDefaultChannelName(),updatedChannel.getName());
assertEquals(updatedConfig.getDefaultChannelDescription(),updatedChannel.getDescription());
}
项目:BlueBolt-Kernel-Tweaking-app
文件:ProximityService.java
@Override
public void onCreate(){
if(DEBUG) Log.i(TAG,"Service Started");
proximitySensorDetails = new ProximitySensorDetails(this);
IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
registerReceiver(screenStateReceiver,screenStateFilter);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationmanager notificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL,"BlueBolt Pocket Mode",notificationmanager.IMPORTANCE_UNSPECIFIED);
notificationmanager.createNotificationChannel(notificationChannel);
PendingIntent pendingIntent = PendingIntent.getActivity(this,new Intent(this,SplashActivity.class),0);
Notification.Builder builder = new Notification.Builder(this,CHANNEL);
builder.setContentTitle(notificationTitle)
.setContentText(notificationText)
.setSmallIcon(R.mipmap.ic_launcher_foreground)
.setContentIntent(pendingIntent)
.setongoing(true);
if(DEBUG) Log.i(TAG,"Notification Created");
startForeground(1,builder.build());
}
}
@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;
}
项目:Aequorea
文件:CacheService.java
private void showNotification() {
mnotificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,getString(R.string.aequorea_offline_cache),notificationmanager.IMPORTANCE_DEFAULT);
mnotificationmanager.createNotificationChannel(channel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(this,CHANNEL_ID).setSmallIcon(R.mipmap.ic_notification)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.caching_offline_article));
if (mnotificationmanager != null) {
mnotificationmanager.notify(1,builder.build());
}
}
项目:GPSTracker-Android
文件:NotificationClass.java
@RequiresApi(Build.VERSION_CODES.O)
public void createMainNotificationChannel(Context c) {
String id = CHANNEL_ID;
String name = CHANNEL_NAME;
String description = CHANNEL_DESCRIPTION;
int importance = notificationmanager.IMPORTANCE_LOW;
NotificationChannel mChannel = new NotificationChannel(id,name,importance);
mChannel.setDescription (description);
mChannel.enableLights(true);
mChannel.setLightColor( Color.RED);
mChannel.enableVibration(true);
notificationmanager mnotificationmanager =
(notificationmanager) c.getSystemService(Context.NOTIFICATION_SERVICE);
// notificationmanager mnotificationmanager = c.getSystemService(Context.NOTIFICATION_SERVICE) as android.app.notificationmanager
mnotificationmanager.createNotificationChannel(mChannel);
}
项目:AgentWeb
文件:Notify.java
public Notify(Context context,int ID) {
this.NOTIFICATION_ID = ID;
mContext = context;
// 获取系统服务来初始化对象
nm = (notificationmanager) mContext
.getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
cBuilder = new NotificationCompat.Builder(mContext,mChannelId = mContext.getPackageName().concat(AGENTWEB_VERSION));
NotificationChannel mNotificationChannel = new NotificationChannel(mChannelId,AgentWebUtils.getApplicationName(context),notificationmanager.IMPORTANCE_DEFAULT);
notificationmanager mnotificationmanager = (notificationmanager) mContext.getSystemService(NOTIFICATION_SERVICE);
mnotificationmanager.createNotificationChannel(mNotificationChannel);
} else {
cBuilder = new NotificationCompat.Builder(mContext);
}
}
项目:Sherlock
文件:CrashReporter.java
public void report(Crashviewmodel crashviewmodel) {
Notification notification = notification(crashviewmodel);
notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID,"Sherlock",IMPORTANCE_DEFAULT
);
notificationmanager.createNotificationChannel(channel);
}
notificationmanager.notify(crashviewmodel.getIdentifier(),notification);
}
项目:MiPushFramework
文件:KeepAliveService.java
public @StartResult int onStartCommand(Intent intent,@StartArgFlags int flags,int startId) {
notificationmanager manager = (notificationmanager)
getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_STATUS,getString(R.string.notification_category_alive),notificationmanager.IMPORTANCE_MIN);
manager.createNotificationChannel(channel);
}
Notification notification = new NotificationCompat.Builder(this,CHANNEL_STATUS)
.setContentTitle(getString(R.string.notification_alive))
.setSmallIcon(R.mipmap.ic_app)
.setPriority(NotificationCompat.PRIORITY_MIN)
.setongoing(true)
.build();
manager.notify(NOTIFICATION_ALIVE_ID,notification);
startForeground(NOTIFICATION_ALIVE_ID,notification);
return START_STICKY;
}
项目:MTweaks-KernelAdiutorMOD
文件:ApplyOnBootService.java
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationmanager notificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID,builder.build());
}
}
项目:fitnotifications
文件:HomeActivity.java
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationmanager manager = (notificationmanager) getSystemService(NOTIFICATION_SERVICE);
String id = Constants.NOTIFICATION_CHANNEL_ID;
CharSequence name = getString(R.string.notification_channel_name);
String desc = getString(R.string.notification_channel_desc);
int importance = notificationmanager.IMPORTANCE_LOW;
NotificationChannel channel = new NotificationChannel(id,importance);
channel.setShowBadge(false);
channel.setDescription(desc);
channel.enableLights(false);
channel.enableVibration(false);
manager.createNotificationChannel(channel);
}
}
项目:chalkboard
文件:Background.java
@TargetApi(26)
private void createNotificationChannel() {
notificationChannelClass = new NotificationChannel("class","Class Notifications",notificationmanager.IMPORTANCE_LOW);
notificationChannelClass.setDescription("Notifications about classes.");
notificationChannelClass.enableLights(false);
notificationChannelClass.enableVibration(false);
notificationChannelClass.setBypassDnd(false);
notificationChannelClass.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationChannelClass.setShowBadge(false);
notificationmanager.createNotificationChannel(notificationChannelClass);
notificationChannelReminder = new NotificationChannel("reminder","Reminders",notificationmanager.IMPORTANCE_MAX);
notificationChannelReminder.setDescription("Notifications about events.");
notificationChannelReminder.enableLights(true);
notificationChannelReminder.setLightColor(sharedPreferences.getInt("primary_color",ContextCompat.getColor(this,R.color.teal)));
notificationChannelReminder.enableVibration(true);
notificationChannelReminder.setBypassDnd(true);
notificationChannelReminder.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationChannelReminder.setShowBadge(true);
notificationmanager.createNotificationChannel(notificationChannelReminder);
}
项目:android-NotificationChannels
文件:NotificationHelper.java
/**
* 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);
}
项目:mediasession-mediaplayer
文件:Medianotificationmanager.java
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
if (mnotificationmanager.getNotificationChannel(CHANNEL_ID) == null) {
// The user-visible name of the channel.
CharSequence name = "MediaSession";
// The user-visible description of the channel.
String description = "MediaSession and MediaPlayer";
int importance = notificationmanager.IMPORTANCE_LOW;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID,importance);
// Configure the notification channel.
mChannel.setDescription(description);
mChannel.enableLights(true);
// Sets the notification light color for notifications posted to this
// channel,if the device supports this feature.
mChannel.setLightColor(Color.RED);
mChannel.enableVibration(true);
mChannel.setVibrationPattern(
new long[]{100,200,300,400,400});
mnotificationmanager.createNotificationChannel(mChannel);
Log.d(TAG,"createChannel: New channel created");
} else {
Log.d(TAG,"createChannel: Existing channel reused");
}
}
项目:Goalie_Android
文件:MessagingService.java
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,importance);
mChannel.setDescription(description);
mChannel.enableLights(true);
mChannel.enableVibration(true);
mnotificationmanager.createNotificationChannel(mChannel);
}
return channelID;
}
项目:okwallet
文件:WalletApplication.java
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);
}
}
项目:PlayAndroid
文件:Medianotificationmanager.java
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
if (mnotificationmanager.getNotificationChannel(CHANNEL_ID) == null) {
// The user-visible name of the channel.
CharSequence name = "MediaSession";
// The user-visible description of the channel.
String description = "MediaSession and MediaPlayer";
int importance = notificationmanager.IMPORTANCE_LOW;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID,"createChannel: Existing channel reused");
}
}
项目:TherapyGuide
文件:NotificationHandler.java
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);
}
}
项目:TherapyGuide
文件:NotificationHandlerTest.java
@TargetApi(26)
@Test
public void createNotificationChannels_createsCorrectChannels() {
try {
setFinalStatic(Build.VERSION.class.getField("SDK_INT"),26);
} catch (Exception e) {
e.printstacktrace();
}
when(mContext.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(mnotificationmanager);
when(mContext.getString(R.string.diary_reminder_notification_channel_name)).thenReturn("Diary Reminder");
when(mContext.getString(R.string.player_notification_channel_name)).thenReturn("Player");
NotificationHandler.createNotificationChannels(mContext);
verify(mnotificationmanager,times(2)).createNotificationChannel(any(NotificationChannel.class));
}
项目:malp
文件:notificationmanager.java
/**
* Creates the {@link NotificationChannel} for devices running Android O or higher
*/
private void openChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,mService.getResources().getString(R.string.notification_channel_name_playback),android.app.notificationmanager.IMPORTANCE_LOW);
// disable lights & vibration
channel.enableVibration(false);
channel.enableLights(false);
channel.setVibrationPattern(null);
// Allow lockscreen playback control
channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC);
// Register the channel
mnotificationmanager.createNotificationChannel(channel);
}
}
项目:rview
文件:NotificationsHelper.java
@TargetApi(Build.VERSION_CODES.O)
public static void createNotificationChannel(Context context,Account account) {
if (AndroidHelper.isApi26OrGreater()) {
final String defaultChannelName = context.getString(
R.string.notifications_default_channel_name,account.getRepositorydisplayName(),account.getAccountdisplayName());
final notificationmanager nm =
(notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.createNotificationChannelGroup(new NotificationChannelGroup(
account.getAccountHash(),defaultChannelName));
NotificationChannel channel = new NotificationChannel(account.getAccountHash(),defaultChannelName,notificationmanager.IMPORTANCE_DEFAULT);
channel.setDescription(context.getString(R.string.notifications_default_channel_description));
channel.enableVibration(true);
channel.enableLights(true);
channel.setLightColor(ContextCompat.getColor(context,R.color.primaryDark));
channel.setShowBadge(true);
channel.setGroup(account.getAccountHash());
nm.createNotificationChannel(channel);
}
}
项目:niddler
文件:OreoCompatHelper.java
public static String createNotificationChannel(@NonNull final Context context) {
final notificationmanager notificationmanager = context.getSystemService(notificationmanager.class);
if (notificationmanager == null) {
return "";
}
final NotificationChannel channel = new NotificationChannel(CHANNEL_ID,CHANNEL_NAME,notificationmanager.IMPORTANCE_LOW);
channel.setDescription(CHANNEL_DESCRIPTION);
channel.enableLights(false);
channel.enableVibration(false);
channel.setBypassDnd(false);
channel.setShowBadge(false);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
notificationmanager.createNotificationChannel(channel);
return CHANNEL_ID;
}
项目:Applozic-Android-Chat-Sample
文件:RegisterUserClientService.java
@RequiresApi(api = Build.VERSION_CODES.O)
void createNotificationChannel(Context context) {
notificationmanager mnotificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name = MobiComKitConstants.PUSH_NOTIFICATION_NAME;
;
int importance = notificationmanager.IMPORTANCE_HIGH;
if (mnotificationmanager.getNotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION) == null) {
NotificationChannel mChannel = new NotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION,importance);
mChannel.enableLights(true);
mChannel.setLightColor(Color.GREEN);
if (Applozicclient.getInstance(context).isUnreadCountBadgeEnabled()) {
mChannel.setShowBadge(true);
} else {
mChannel.setShowBadge(false);
}
if (Applozicclient.getInstance(context).getVibrationOnNotification()) {
mChannel.enableVibration(true);
mChannel.setVibrationPattern(new long[]{100,400});
}
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_ringtone).build();
mChannel.setSound(ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION),audioAttributes);
mnotificationmanager.createNotificationChannel(mChannel);
}
}
项目:focus-android
文件:SessionNotificationService.java
public void createNotificationChannelIfNeeded() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
// Notification channels are only available on Android O or higher.
return;
}
final notificationmanager notificationmanager = getSystemService(notificationmanager.class);
if (notificationmanager == null) {
return;
}
final String notificationChannelName = getString(R.string.notification_browsing_session_channel_name);
final String notificationChannelDescription = getString(
R.string.notification_browsing_session_channel_description,getString(R.string.app_name));
final NotificationChannel channel = new NotificationChannel(
NOTIFICATION_CHANNEL_ID,notificationChannelName,notificationmanager.IMPORTANCE_MIN);
channel.setImportance(notificationmanager.IMPORTANCE_LOW);
channel.setDescription(notificationChannelDescription);
channel.enableLights(false);
channel.enableVibration(false);
channel.setShowBadge(true);
notificationmanager.createNotificationChannel(channel);
}
项目:dns66
文件:NotificationChannels.java
public static void onCreate(Context context) {
notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
return;
notificationmanager.createNotificationChannelGroup(new NotificationChannelGroup(GROUP_SERVICE,context.getString(R.string.notifications_group_service)));
notificationmanager.createNotificationChannelGroup(new NotificationChannelGroup(GROUP_UPDATE,context.getString(R.string.notifications_group_updates)));
NotificationChannel runningChannel = new NotificationChannel(SERVICE_RUNNING,context.getString(R.string.notifications_running),notificationmanager.IMPORTANCE_MIN);
runningChannel.setDescription(context.getString(R.string.notifications_running_desc));
runningChannel.setGroup(GROUP_SERVICE);
runningChannel.setShowBadge(false);
notificationmanager.createNotificationChannel(runningChannel);
NotificationChannel pausedChannel = new NotificationChannel(SERVICE_PAUSED,context.getString(R.string.notifications_paused),notificationmanager.IMPORTANCE_LOW);
pausedChannel.setDescription(context.getString(R.string.notifications_paused_desc));
pausedChannel.setGroup(GROUP_SERVICE);
pausedChannel.setShowBadge(false);
notificationmanager.createNotificationChannel(pausedChannel);
NotificationChannel updateChannel = new NotificationChannel(UPDATE_STATUS,context.getString(R.string.notifications_update),notificationmanager.IMPORTANCE_LOW);
updateChannel.setDescription(context.getString(R.string.notifications_update_desc));
updateChannel.setGroup(GROUP_UPDATE);
updateChannel.setShowBadge(false);
notificationmanager.createNotificationChannel(updateChannel);
}
项目:xDrip
文件:NotificationChannels.java
@TargetApi(26)
private static int myhashcode(NotificationChannel x) {
int result = x.getId() != null ? x.getId().hashCode() : 0;
//result = 31 * result + (getName() != null ? getName().hashCode() : 0);
//result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
//result = 31 * result + getImportance();
//result = 31 * result + (mBypassDnd ? 1 : 0);
//result = 31 * result + getLockscreenVisibility();
result = 31 * result + (x.getSound() != null ? x.getSound().hashCode() : 0);
//result = 31 * result + (x.mLights ? 1 : 0);
result = 31 * result + x.getLightColor();
result = 31 * result + Arrays.hashCode(x.getVibrationPattern());
//result = 31 * result + getUserLockedFields();
//result = 31 * result + (mVibrationEnabled ? 1 : 0);
//result = 31 * result + (mShowBadge ? 1 : 0);
//result = 31 * result + (isDeleted() ? 1 : 0);
//result = 31 * result + (getGroup() != null ? getGroup().hashCode() : 0);
//result = 31 * result + (getAudioAttributes() != null ? getAudioAttributes().hashCode() : 0);
//result = 31 * result + (isBlockableSystem() ? 1 : 0);
return result;
}
项目:xDrip
文件:NotificationChannels.java
@TargetApi(26)
public static boolean isSoundDifferent(String id,NotificationChannel x) {
if (x.getSound() == null) return false; // this does not have a sound
final NotificationChannel c = getNotifManager().getNotificationChannel(id);
if (c == null) return false; // no channel with this id
if (c.getSound() == null)
return false; // this maybe will only happen if user disables sound so lets not create a new one in that case
final String original_sound = PersistentStore.getString("original-channel-sound-" + id);
if (original_sound.equals("")) {
PersistentStore.setString("original-channel-sound-" + id,x.getSound().toString());
return false; // no existing record so save the original and do nothing else
}
if (original_sound.equals(x.getSound().toString()))
return false; // its the same sound still
return true; // the sound has changed vs the original
}
项目:GeometricWeather
文件:NotificationUtils.java
private static void senDalertNotification(Context c,String cityName,Alert alert) {
notificationmanager manager = ((notificationmanager) c.getSystemService(Context.NOTIFICATION_SERVICE));
if (manager != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID_ALERT,c.getString(R.string.app_name) + " " + c.getString(R.string.action_alert),notificationmanager.IMPORTANCE_DEFAULT);
channel.setShowBadge(true);
manager.createNotificationChannel(channel);
}
manager.notify(
getNotificationId(c),buildSingleNotification(c,cityName,alert));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
manager.notify(NOTIFICATION_GROUP_SUMMARY_ID,buildGroupSummaryNotification(c,alert));
}
}
}
项目:xDrip-plus
文件:NotificationChannels.java
@TargetApi(26)
private static int myhashcode(NotificationChannel x) {
int result = x.getId() != null ? x.getId().hashCode() : 0;
//result = 31 * result + (getName() != null ? getName().hashCode() : 0);
//result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
//result = 31 * result + getImportance();
//result = 31 * result + (mBypassDnd ? 1 : 0);
//result = 31 * result + getLockscreenVisibility();
result = 31 * result + (x.getSound() != null ? x.getSound().hashCode() : 0);
//result = 31 * result + (x.mLights ? 1 : 0);
result = 31 * result + x.getLightColor();
result = 31 * result + Arrays.hashCode(x.getVibrationPattern());
//result = 31 * result + getUserLockedFields();
//result = 31 * result + (mVibrationEnabled ? 1 : 0);
//result = 31 * result + (mShowBadge ? 1 : 0);
//result = 31 * result + (isDeleted() ? 1 : 0);
//result = 31 * result + (getGroup() != null ? getGroup().hashCode() : 0);
//result = 31 * result + (getAudioAttributes() != null ? getAudioAttributes().hashCode() : 0);
//result = 31 * result + (isBlockableSystem() ? 1 : 0);
return result;
}
项目:xDrip-plus
文件:NotificationChannels.java
@TargetApi(26)
public static boolean isSoundDifferent(String id,x.getSound().toString());
return false; // no existing record so save the original and do nothing else
}
if (original_sound.equals(x.getSound().toString()))
return false; // its the same sound still
return true; // the sound has changed vs the original
}
项目:TrebleShot
文件:NotificationUtils.java
public NotificationUtils(Context context)
{
mContext = context;
mManager = notificationmanagerCompat.from(context);
mDatabase = new AccessDatabase(context);
mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channelHigh = new NotificationChannel(NOTIFICATION_CHANNEL_HIGH,mContext.getString(R.string.text_appName),notificationmanager.IMPORTANCE_HIGH);
channelHigh.enableLights(mPreferences.getBoolean("notification_light",false));
channelHigh.enableVibration(mPreferences.getBoolean("notification_vibrate",false));
notificationmanager.createNotificationChannel(channelHigh);
NotificationChannel channelLow = new NotificationChannel(NOTIFICATION_CHANNEL_LOW,notificationmanager.IMPORTANCE_NONE);
notificationmanager.createNotificationChannel(channelLow);
}
}
项目:kcanotify
文件:KcaAlarmService.java
private void createalarmChannel(String uri) {
Log.e("KCA-A","recv: " + uri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String soundKind = getStringPreferences(getApplicationContext(),PREF_KCA_NOTI_SOUND_KIND);
boolean isVibrate = soundKind.equals(getString(R.string.sound_kind_value_mixed)) || soundKind.equals(getString(R.string.sound_kind_value_vibrate));
notificationmanager.deleteNotificationChannel(ALARM_CHANNEL_ID);
while (!alarmChannelList.isEmpty()) {
notificationmanager.deleteNotificationChannel(alarmChannelList.poll());
}
AudioAttributes.Builder attrs = new AudioAttributes.Builder();
attrs.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION);
attrs.setUsage(AudioAttributes.USAGE_NOTIFICATION);
String channel_name = createalarmId(uri,isVibrate);
alarmChannelList.add(channel_name);
NotificationChannel channel = new NotificationChannel(alarmChannelList.peek(),getStringWithLocale(R.string.notification_appinfo_title),notificationmanager.IMPORTANCE_HIGH);
channel.setSound(Uri.parse(uri),attrs.build());
channel.enableVibration(isVibrate);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
notificationmanager.createNotificationChannel(channel);
}
}
项目:NMAkademija
文件:NMAFirebaseMessagingService.java
@Override
public void onCreate() {
super.onCreate();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
notificationmanager notificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notificationChannel =
new NotificationChannel(
CHANNEL_ID,getString(R.string.notifications),notificationmanager.IMPORTANCE_DEFAULT);
notificationmanager.createNotificationChannel(notificationChannel);
}
}
private void initDefaultChannel() {
if (Build.VERSION.SDK_INT < 26) {
return;
}
final notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationmanager == null) {
return;
}
final CharSequence channelName = Software@R_910_404[email protected](context);
final int importance = notificationmanager.IMPORTANCE_DEFAULT;
final NotificationChannel notificationChannel = new NotificationChannel(MM_DEFAULT_CHANNEL_ID,importance);
notificationChannel.enableLights(true);
notificationChannel.enableVibration(true);
notificationmanager.createNotificationChannel(notificationChannel);
}
项目:odyssey
文件:Odysseynotificationmanager.java
/**
* Creates the {@link NotificationChannel} for devices running Android O or higher
*/
private void openChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,mContext.getResources().getString(R.string.notification_channel_playback),android.app.notificationmanager.IMPORTANCE_LOW);
// disable lights & vibration
channel.enableVibration(false);
channel.enableLights(false);
channel.setVibrationPattern(null);
// Allow lockscreen playback control
channel.setLockscreenVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC);
// Register the channel
mnotificationmanager.createNotificationChannel(channel);
}
}
项目:trackbook
文件:NotificationHelper.java
public static boolean createNotificationChannel(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// API level 26 ("Android O") supports notification channels.
String id = NOTIFICATION_CHANEL_ID_RECORDING_CHANNEL;
CharSequence name = context.getString(R.string.notification_channel_recording_name);
String description = context.getString(R.string.notification_channel_recording_description);
int importance = notificationmanager.IMPORTANCE_LOW;
// create channel
NotificationChannel channel = new NotificationChannel(id,importance);
channel.setDescription(description);
notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.createNotificationChannel(channel);
return true;
} else {
return false;
}
}
项目:Blackbulb
文件:BlackbulbApplication.java
@TargetApi(Build.VERSION_CODES.O)
public void createNotificationChannel() {
notificationmanager notificationmanager = getSystemService(notificationmanager.class);
if (notificationmanager != null) {
NotificationChannel channel = new NotificationChannel(
Constants.NOTIFICATION_CHANNEL_ID_RS,getString(R.string.notification_channel_running_status),notificationmanager.IMPORTANCE_DEFAULT
);
channel.setShowBadge(false);
channel.enableLights(false);
channel.enableVibration(false);
channel.setSound(null,null);
notificationmanager.createNotificationChannel(channel);
}
}
项目:Hover
文件:BaseWindow.java
@Override
protected void onCreate(@Nullable Bundle arguments) {
super.onCreate(arguments);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,"Floating windows",notificationmanager.IMPORTANCE_DEFAULT);
notificationmanager notificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationmanager != null) {
notificationmanager.createNotificationChannel(channel);
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。