當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。