当前位置: 首页>>代码示例>>Java>>正文


Java NotificationChannel.getId方法代码示例

本文整理汇总了Java中android.app.NotificationChannel.getId方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationChannel.getId方法的具体用法?Java NotificationChannel.getId怎么用?Java NotificationChannel.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.NotificationChannel的用法示例。


在下文中一共展示了NotificationChannel.getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: myhashcode

import android.app.NotificationChannel; //导入方法依赖的package包/类
@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;

}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:24,代码来源:NotificationChannels.java

示例2: getNotificationBuilder

import android.app.NotificationChannel; //导入方法依赖的package包/类
private NotificationCompat.Builder getNotificationBuilder(NotificationChannel channel) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        return new NotificationCompat.Builder(mContext, channel.getId());
    } else {
        //noinspection deprecation
        return new NotificationCompat.Builder(mContext);
    }
}
 
开发者ID:syncthing,项目名称:syncthing-android,代码行数:9,代码来源:NotificationHandler.java

示例3: getChan

import android.app.NotificationChannel; //导入方法依赖的package包/类
@TargetApi(26)
public static NotificationChannel getChan(NotificationCompat.Builder wip) {

    final Notification temp = wip.build();
    if (temp.getChannelId() == null) return null;

    // create generic audio attributes
    final AudioAttributes generic_audio = new AudioAttributes.Builder()
            .setUsage(AudioAttributes.USAGE_NOTIFICATION)
            .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
            .build();

    // create notification channel for hashing purposes from the existing notification builder
    NotificationChannel template = new NotificationChannel(
            temp.getChannelId(),
            getString(temp.getChannelId()),
            NotificationManager.IMPORTANCE_DEFAULT);


    // mirror the notification parameters in the channel
    template.setGroup(temp.getChannelId());
    template.setVibrationPattern(wip.mNotification.vibrate);
    template.setSound(wip.mNotification.sound, generic_audio);
    template.setLightColor(wip.mNotification.ledARGB);
    if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0))
        template.enableLights(true); // weird how this doesn't work like vibration pattern
    template.setDescription(temp.getChannelId() + " " + wip.hashCode());

    // get a nice string to identify the hash
    final String mhash = my_text_hash(template);

    // create another notification channel using the hash because id is immutable
    final NotificationChannel channel = new NotificationChannel(
            template.getId() + mhash,
            getString(temp.getChannelId()) + mhash,
            NotificationManager.IMPORTANCE_DEFAULT);

    // mirror the settings from the previous channel
    channel.setSound(template.getSound(), generic_audio);
    channel.setGroup(template.getGroup());
    channel.setDescription(template.getDescription());
    channel.setVibrationPattern(template.getVibrationPattern());
    template.setLightColor(wip.mNotification.ledARGB);
    if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0))
        template.enableLights(true); // weird how this doesn't work like vibration pattern
    template.setDescription(temp.getChannelId() + " " + wip.hashCode());

    // create a group to hold this channel if one doesn't exist or update text
    getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup())));
    // create this channel if it doesn't exist or update text
    getNotifManager().createNotificationChannel(channel);
    return channel;
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:54,代码来源:NotificationChannels.java


注:本文中的android.app.NotificationChannel.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。