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


Java NotificationManager.IMPORTANCE_MIN属性代码示例

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


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

示例1: onStartCommand

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;
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:20,代码来源:KeepAliveService.java

示例2: createNotificationChannel

public void createNotificationChannel() {
    if (Build.VERSION.SDK_INT >= 26) {
        NotificationChannel channel = new NotificationChannel(nId, nName,
                NotificationManager.IMPORTANCE_MIN);
        getManager().createNotificationChannel(channel);
    }
}
 
开发者ID:838030195,项目名称:DaiGo,代码行数:7,代码来源:NotificationUtil.java

示例3: createNotificationChannel

private void createNotificationChannel() {
    NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String id = ACCOUNT_TRANSFER_CHANNEL;
    CharSequence name = "AccountTransfer";
    String description = "Account Transfer";
    int importance = NotificationManager.IMPORTANCE_MIN;
    NotificationChannel mChannel = new NotificationChannel(id, name, importance);
    mChannel.setDescription(description);
    mChannel.enableLights(false);
    mChannel.enableVibration(false);
    mNotificationManager.createNotificationChannel(mChannel);
}
 
开发者ID:googlesamples,项目名称:account-transfer-api,代码行数:13,代码来源:AccountTransferService.java

示例4: 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);
        }


    }
 
开发者ID:zeevy,项目名称:grblcontroller,代码行数:32,代码来源:NotificationHelper.java

示例5: onCreate

@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.data_sharing), NotificationManager.IMPORTANCE_MIN);
        notificationManager.createNotificationChannel(notificationChannel);

        PendingIntent disableIntent = PendingIntent.getBroadcast(this, 1,
                new Intent(this, DisableReceiver.class),
                PendingIntent.FLAG_UPDATE_CURRENT);

        Intent launchIntent = new Intent(this, MainActivity.class);
        launchIntent.setAction(Intent.ACTION_VIEW);
        launchIntent.putExtra("section", DataSharingFragment.class.getCanonicalName());
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                launchIntent, 0);

        /*
        Notification.Builder builder =
                new Notification.Builder(this, CHANNEL_ID);
        builder.setContentTitle(getString(R.string.data_sharing))
                .setContentText(getString(R.string.data_sharing_summary_notification))
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentIntent(contentIntent)
                .addAction(0, getString(R.string.disable), disableIntent);
        startForeground(NotificationId.MONITOR, builder.build());
        */
    }

    registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    IntentFilter screenFilter = new IntentFilter();
    screenFilter.addAction(Intent.ACTION_SCREEN_OFF);
    screenFilter.addAction(Intent.ACTION_SCREEN_ON);
    registerReceiver(mScreenReceiver, screenFilter);

    mScreenOn = Utils.isScreenOn(this);
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:43,代码来源:Monitor.java

示例6: onCreate

@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.data_sharing), NotificationManager.IMPORTANCE_MIN);
        notificationManager.createNotificationChannel(notificationChannel);

        PendingIntent disableIntent = PendingIntent.getBroadcast(this, 1,
                new Intent(this, DisableReceiver.class),
                PendingIntent.FLAG_UPDATE_CURRENT);

        Intent launchIntent = new Intent(this, MainActivity.class);
        launchIntent.setAction(Intent.ACTION_VIEW);
        launchIntent.putExtra("section", DataSharingFragment.class.getCanonicalName());
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                launchIntent, 0);

        Notification.Builder builder =
                new Notification.Builder(this, CHANNEL_ID);
        builder.setContentTitle(getString(R.string.data_sharing))
                .setContentText(getString(R.string.data_sharing_summary_notification))
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentIntent(contentIntent)
                .addAction(0, getString(R.string.disable), disableIntent);
        startForeground(NotificationId.MONITOR, builder.build());
    }

    registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    IntentFilter screenFilter = new IntentFilter();
    screenFilter.addAction(Intent.ACTION_SCREEN_OFF);
    screenFilter.addAction(Intent.ACTION_SCREEN_ON);
    registerReceiver(mScreenReceiver, screenFilter);

    mScreenOn = Utils.isScreenOn(this);
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:41,代码来源:Monitor.java


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