Java Code Examples for android.app.NotificationChannel#setShowBadge()

The following examples show how to use android.app.NotificationChannel#setShowBadge() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadManager.java    From QuranAndroid with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Init notification channels for android 8.0 and higher
 */
private String createNotificationChannel(Context context) {
    // Create the NotificationChannel, but only on API 26+ because
    // the NotificationChannel class is new and not in the support library
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

        int importance = NotificationManager.IMPORTANCE_LOW;
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, importance);
        channel.setDescription(CHANNEL_DESCRIPTION);
        channel.enableLights(true);
        channel.setLightColor(Color.RED);
        channel.setShowBadge(true);
        channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
        // Register the channel with the system; you can't change the importance
        // or other notification behaviors after this
        NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
        notificationManager.createNotificationChannel(channel);
    }
    return CHANNEL_ID;
}
 
Example 2
Source File: MainActivity.java    From service with Apache License 2.0 6 votes vote down vote up
/**
 * for API 26+ create notification channels
 */
private void createchannel() {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationChannel mChannel = new NotificationChannel(id,
            getString(R.string.channel_name),  //name of the channel
            NotificationManager.IMPORTANCE_DEFAULT);   //importance level
        //important level: default is is high on the phone.  high is urgent on the phone.  low is medium, so none is low?
        // Configure the notification channel.
        mChannel.setDescription(getString(R.string.channel_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.setShowBadge(true);
        mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        nm.createNotificationChannel(mChannel);

    }
}
 
Example 3
Source File: PlayerNotification.java    From blade-player with GNU General Public License v3.0 6 votes vote down vote up
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel()
{
    NotificationManager mNotificationManager = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
    // The id of the channel.
    // The user-visible name of the channel.
    CharSequence name = "Media playback";
    // The user-visible description of the channel.
    String description = "Media playback controls";
    int importance = NotificationManager.IMPORTANCE_LOW;
    NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
    // Configure the notification channel.
    mChannel.setDescription(description);
    mChannel.setShowBadge(false);
    mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    mNotificationManager.createNotificationChannel(mChannel);
}
 
Example 4
Source File: MediaPlayerService.java    From AudioAnchor with GNU General Public License v3.0 6 votes vote down vote up
private void createNotificationChannel() {
    // Create the NotificationChannel, but only on API 26+ because
    // the NotificationChannel class is new and not in the support library
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = getString(R.string.channel_name);
        String description = getString(R.string.channel_description);
        int importance = NotificationManager.IMPORTANCE_DEFAULT;
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
        channel.setDescription(description);
        channel.setSound(null, null);
        channel.setShowBadge(false);
        // Register the channel with the system; you can't change the importance
        // or other notification behaviors after this
        NotificationManager notificationManager = getSystemService(NotificationManager.class);
        if (notificationManager != null) {
            notificationManager.createNotificationChannel(channel);
        }
    }
}
 
Example 5
Source File: NotificationChannels.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
private synchronized void createNotificationChannel() {
    CharSequence name = MobiComKitConstants.PUSH_NOTIFICATION_NAME;
    int importance = NotificationManager.IMPORTANCE_HIGH;

    if (mNotificationManager != null && mNotificationManager.getNotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION) == null) {
        NotificationChannel mChannel = new NotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION, name, importance);
        mChannel.enableLights(true);
        mChannel.setLightColor(Color.GREEN);
        mChannel.setShowBadge(ApplozicClient.getInstance(context).isUnreadCountBadgeEnabled());

        if (ApplozicClient.getInstance(context).getVibrationOnNotification()) {
            mChannel.enableVibration(true);
            mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        }

        AudioAttributes audioAttributes = new AudioAttributes.Builder()
                .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                .setUsage(AudioAttributes.USAGE_NOTIFICATION).build();
        mChannel.setSound(TextUtils.isEmpty(soundFilePath) ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) : Uri.parse(soundFilePath), audioAttributes);
        mNotificationManager.createNotificationChannel(mChannel);
        Utils.printLog(context, TAG, "Created notification channel");
    }
}
 
Example 6
Source File: NotificationChannels.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
private synchronized void createSilentNotificationChannel() {
    CharSequence name = MobiComKitConstants.SILENT_PUSH_NOTIFICATION;
    int importance = NotificationManager.IMPORTANCE_LOW;
    if (mNotificationManager != null && mNotificationManager.getNotificationChannel(MobiComKitConstants.AL_SILENT_NOTIFICATION) == null) {
        NotificationChannel mChannel = new NotificationChannel(MobiComKitConstants.AL_SILENT_NOTIFICATION, name, importance);
        mChannel.enableLights(true);
        mChannel.setLightColor(Color.GREEN);
        if (ApplozicClient.getInstance(context).isUnreadCountBadgeEnabled()) {
            mChannel.setShowBadge(true);
        } else {
            mChannel.setShowBadge(false);
        }

        mNotificationManager.createNotificationChannel(mChannel);
        Utils.printLog(context, TAG, "Created silent notification channel");
    }
}
 
Example 7
Source File: NotificationHandler.java    From Bop with Apache License 2.0 5 votes vote down vote up
/**
 * Creates Notification Channel. This is required in Android O+ to display notifications.
 */
@RequiresApi(Build.VERSION_CODES.O)
private void createNotificationChannel() {
    if (mNotificationManager.getNotificationChannel(CHANNEL_ID) == null) {
        NotificationChannel notificationChannel =
                new NotificationChannel(CHANNEL_ID, "Bop",
                        android.app.NotificationManager.IMPORTANCE_LOW);

        notificationChannel.setDescription("Music player");
        notificationChannel.setShowBadge(false);
        notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
        mNotificationManager.createNotificationChannel(notificationChannel);
    }
}
 
Example 8
Source File: NotificationHelper.java    From grblcontroller with GNU General Public License v3.0 5 votes vote down vote up
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_DEFAULT);
            mChannelThree.setDescription(CHANNEL_SERVICE_ABOUT);
            mChannelThree.enableLights(false);
            mChannelThree.enableVibration(false);
            mChannelThree.setLightColor(getColor(R.color.colorPrimary));
            mChannelThree.setShowBadge(true);
            mChannelThree.setSound(null, null);
            getNotificationManager().createNotificationChannel(mChannelThree);
        }
    }
 
Example 9
Source File: LocationService.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
NotificationChannel getLocationNotificationChannel(Context context) {
    NotificationChannel channel = new NotificationChannel(
            GeometricWeather.NOTIFICATION_CHANNEL_ID_LOCATION,
            GeometricWeather.getNotificationChannelName(
                    context, GeometricWeather.NOTIFICATION_CHANNEL_ID_LOCATION),
            NotificationManager.IMPORTANCE_MIN);
    channel.setShowBadge(false);
    channel.setLightColor(ContextCompat.getColor(context, R.color.colorPrimary));
    return channel;
}
 
Example 10
Source File: MapTrek.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(26)
private void createNotificationChannel() {
    NotificationChannel channel = new NotificationChannel("ongoing",
            getString(R.string.notificationChannelName), NotificationManager.IMPORTANCE_LOW);
    channel.setShowBadge(false);
    channel.setSound(null, null);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    if (notificationManager != null)
        notificationManager.createNotificationChannel(channel);
}
 
Example 11
Source File: FloatWindowService.java    From FloatWindow with Apache License 2.0 5 votes vote down vote up
private void createNotificationChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = "Name";
        String description = "Description";
        int importance = NotificationManager.IMPORTANCE_DEFAULT;
        NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
        channel.setDescription(description);
        channel.setShowBadge(false);
        NotificationManager notificationManager = getSystemService(NotificationManager.class);
        if (notificationManager != null) {
            notificationManager.createNotificationChannel(channel);
        }
    }
}
 
Example 12
Source File: ToolboxApplication.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
		DfuServiceInitiator.createDfuNotificationChannel(this);

		final NotificationChannel channel = new NotificationChannel(CONNECTED_DEVICE_CHANNEL, getString(R.string.channel_connected_devices_title), NotificationManager.IMPORTANCE_LOW);
		channel.setDescription(getString(R.string.channel_connected_devices_description));
		channel.setShowBadge(false);
		channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);

		final NotificationChannel fileChannel = new NotificationChannel(FILE_SAVED_CHANNEL, getString(R.string.channel_files_title), NotificationManager.IMPORTANCE_LOW);
		fileChannel.setDescription(getString(R.string.channel_files_description));
		fileChannel.setShowBadge(false);
		fileChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);

		final NotificationChannel proximityChannel = new NotificationChannel(PROXIMITY_WARNINGS_CHANNEL, getString(R.string.channel_proximity_warnings_title), NotificationManager.IMPORTANCE_LOW);
		proximityChannel.setDescription(getString(R.string.channel_proximity_warnings_description));
		proximityChannel.setShowBadge(false);
		proximityChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);

		final NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
		notificationManager.createNotificationChannel(channel);
		notificationManager.createNotificationChannel(fileChannel);
		notificationManager.createNotificationChannel(proximityChannel);
	}
}
 
Example 13
Source File: MageApplication.java    From mage-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();

	//This ensures the singleton is created with the correct context, which needs to be the
	//application context
	DaoStore.getInstance(this.getApplicationContext());
	LayerHelper.getInstance(this.getApplicationContext());
	StaticFeatureHelper.getInstance(this.getApplicationContext());

	ProcessLifecycleOwner.get().getLifecycle().addObserver(this);

	HttpClientManager.initialize(this);

	// setup the screen unlock stuff
	registerReceiver(ScreenChangeReceiver.getInstance(), new IntentFilter(Intent.ACTION_SCREEN_ON));

	registerActivityLifecycleCallbacks(this);

	SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
	int dayNightTheme = preferences.getInt(getResources().getString(R.string.dayNightThemeKey), getResources().getInteger(R.integer.dayNightThemeDefaultValue));
	AppCompatDelegate.setDefaultNightMode(dayNightTheme);

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
		NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
		NotificationChannel channel = new NotificationChannel(MAGE_NOTIFICATION_CHANNEL_ID,"MAGE", NotificationManager.IMPORTANCE_LOW);
		channel.setShowBadge(true);
		notificationManager.createNotificationChannel(channel);

		NotificationChannel observationChannel = new NotificationChannel(MAGE_OBSERVATION_NOTIFICATION_CHANNEL_ID,"MAGE Observations", NotificationManager.IMPORTANCE_HIGH);
		observationChannel.setShowBadge(true);
		notificationManager.createNotificationChannel(observationChannel);
	}
}
 
Example 14
Source File: ITagsService.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
private static void createForegroundNotificationChannel(Context context) {
    if (!createdForegroundChannel && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = context.getString(R.string.app_name);
        int importance = NotificationManager.IMPORTANCE_MIN;
        NotificationChannel channel = new NotificationChannel(FOREGROUND_CHANNEL_ID, name, importance);
        channel.setSound(null, null);
        channel.setShowBadge(false);
        NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
        if (notificationManager != null) {
            notificationManager.createNotificationChannel(channel);
            createdForegroundChannel = true;
        }
    }
}
 
Example 15
Source File: SteamService.java    From UpdogFarmer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create notification channel for Android O
 */
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
    final CharSequence name = getString(R.string.channel_name);
    final int importance = NotificationManager.IMPORTANCE_LOW;
    final NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
    channel.setShowBadge(false);
    channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    channel.enableVibration(false);
    channel.enableLights(false);
    channel.setBypassDnd(false);
    final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.createNotificationChannel(channel);
}
 
Example 16
Source File: MusicControlModule.java    From react-native-music-control with MIT License 5 votes vote down vote up
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel(ReactApplicationContext context) {
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, "Media playback", NotificationManager.IMPORTANCE_LOW);
    mChannel.setDescription("Media playback controls");
    mChannel.setShowBadge(false);
    mChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC);
    mNotificationManager.createNotificationChannel(mChannel);
}
 
Example 17
Source File: DCCNotificationManager.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
private void createNotificationChannel() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
        return;
    NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL,
            mContext.getString(R.string.notification_channel_dcc),
            NotificationManager.IMPORTANCE_DEFAULT);
    channel.setShowBadge(false);
    mNotificationManager.createNotificationChannel(channel);
}
 
Example 18
Source File: NotificationSupport.java    From android with MIT License 4 votes vote down vote up
@RequiresApi(Build.VERSION_CODES.O)
public static void createChannels(NotificationManager notificationManager) {
    try {
        // Low importance so that persistent notification can be sorted towards bottom of
        // notification shade. Also prevents vibrations caused by persistent notification
        NotificationChannel foreground =
                new NotificationChannel(
                        Channel.FOREGROUND,
                        "Gotify foreground notification",
                        NotificationManager.IMPORTANCE_LOW);
        foreground.setShowBadge(false);

        NotificationChannel messagesImportanceMin =
                new NotificationChannel(
                        Channel.MESSAGES_IMPORTANCE_MIN,
                        "Min priority messages (<1)",
                        NotificationManager.IMPORTANCE_MIN);

        NotificationChannel messagesImportanceLow =
                new NotificationChannel(
                        Channel.MESSAGES_IMPORTANCE_LOW,
                        "Low priority messages (1-3)",
                        NotificationManager.IMPORTANCE_LOW);

        NotificationChannel messagesImportanceDefault =
                new NotificationChannel(
                        Channel.MESSAGES_IMPORTANCE_DEFAULT,
                        "Normal priority messages (4-7)",
                        NotificationManager.IMPORTANCE_DEFAULT);
        messagesImportanceDefault.enableLights(true);
        messagesImportanceDefault.setLightColor(Color.CYAN);
        messagesImportanceDefault.enableVibration(true);

        NotificationChannel messagesImportanceHigh =
                new NotificationChannel(
                        Channel.MESSAGES_IMPORTANCE_HIGH,
                        "High priority messages (>7)",
                        NotificationManager.IMPORTANCE_HIGH);
        messagesImportanceHigh.enableLights(true);
        messagesImportanceHigh.setLightColor(Color.CYAN);
        messagesImportanceHigh.enableVibration(true);

        notificationManager.createNotificationChannel(foreground);
        notificationManager.createNotificationChannel(messagesImportanceMin);
        notificationManager.createNotificationChannel(messagesImportanceLow);
        notificationManager.createNotificationChannel(messagesImportanceDefault);
        notificationManager.createNotificationChannel(messagesImportanceHigh);
    } catch (Exception e) {
        Log.e("Could not create channel", e);
    }
}
 
Example 19
Source File: NotificationHelper.java    From PermissionEverywhere with Apache License 2.0 4 votes vote down vote up
public static void sendNotification(Context context,
                                    String[] permissions,
                                    int requestCode,
                                    String notificationTitle,
                                    String notificationText,
                                    int notificationIcon,
                                    ResultReceiver receiver) {

    Intent intent = new Intent(context, PermissionActivity.class);
    intent.putExtra(Const.REQUEST_CODE, requestCode);
    intent.putExtra(Const.PERMISSIONS_ARRAY, permissions);
    intent.putExtra(Const.RESULT_RECEIVER, receiver);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(context, REQUEST_CODE_PUSH, intent,
            PendingIntent.FLAG_ONE_SHOT);

    NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, context.getString(R.string.channel_name), NotificationManager.IMPORTANCE_HIGH);
        notificationChannel.enableLights(true);
        notificationChannel.setLightColor(Color.RED);
        notificationChannel.setShowBadge(true);
        notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
        notificationManager.createNotificationChannel(notificationChannel);
    }

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID)
            .setSmallIcon(notificationIcon)
            .setContentTitle(notificationTitle)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(notificationText))
            .setContentText(notificationText)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setVibrate(new long[0])
            .setContentIntent(pendingIntent);

    notificationManager.notify(requestCode, notificationBuilder.build());
}
 
Example 20
Source File: NotificationUtil.java    From QuickLyric with GNU General Public License v3.0 4 votes vote down vote up
public static Notification makeNotification(Context context, String artist, String track, long duration, boolean retentionNotif, boolean isPlaying) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    boolean prefOverlay = sharedPref.getBoolean("pref_overlay", false) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(context));
    int notificationPref = prefOverlay ? 2 : Integer.valueOf(sharedPref.getString("pref_notifications", "0"));

    Intent activityIntent = new Intent(context.getApplicationContext(), MainActivity.class)
            .setAction("com.geecko.QuickLyric.getLyrics")
            .putExtra("retentionNotif", retentionNotif)
            .putExtra("TAGS", new String[]{artist, track});
    Intent wearableIntent = new Intent("com.geecko.QuickLyric.SEND_TO_WEARABLE")
            .putExtra("artist", artist).putExtra("track", track).putExtra("duration", duration);
    final Intent overlayIntent = new Intent(context.getApplicationContext(), LyricsOverlayService.class)
            .setAction(LyricsOverlayService.CLICKED_FLOATING_ACTION);

    PendingIntent overlayPending = PendingIntent.getService(context.getApplicationContext(), 0, overlayIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    PendingIntent openAppPending = PendingIntent.getActivity(context.getApplicationContext(), 0, activityIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    PendingIntent wearablePending = PendingIntent.getBroadcast(context.getApplicationContext(), 8, wearableIntent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Action wearableAction =
            new NotificationCompat.Action.Builder(R.drawable.ic_watch,
                    context.getString(R.string.wearable_prompt), wearablePending)
                    .build();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(notificationPref == 1 && isPlaying ? TRACK_NOTIF_CHANNEL : TRACK_NOTIF_HIDDEN_CHANNEL,
                context.getString(R.string.pref_notifications),
                notificationPref == 1 && isPlaying ? NotificationManager.IMPORTANCE_LOW : NotificationManager.IMPORTANCE_MIN);
        notificationChannel.setShowBadge(false);
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(notificationChannel);
    }

    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context.getApplicationContext(), notificationPref == 1 && isPlaying ? TRACK_NOTIF_CHANNEL : TRACK_NOTIF_HIDDEN_CHANNEL);
    NotificationCompat.Builder wearableNotifBuilder = new NotificationCompat.Builder(context.getApplicationContext(), TRACK_NOTIF_HIDDEN_CHANNEL);

    int[] themes = new int[]{R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red,
            R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo,
            R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime,
            R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark};
    int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0"));

    context.setTheme(themes[themeNum]);

    notifBuilder.setSmallIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.ic_notif : R.drawable.ic_notif4)
            .setContentTitle(context.getString(R.string.app_name))
            .setContentText(String.format("%s - %s", artist, track))
            .setContentIntent(prefOverlay ? overlayPending : openAppPending)
            .setVisibility(-1) // Notification.VISIBILITY_SECRET
            .setGroup("Lyrics_Notification")
            .setColor(ColorUtils.getPrimaryColor(context))
            .setShowWhen(false)
            .setGroupSummary(true);

    wearableNotifBuilder.setSmallIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.ic_notif : R.drawable.ic_notif4)
            .setContentTitle(context.getString(R.string.app_name))
            .setContentText(String.format("%s - %s", artist, track))
            .setContentIntent(openAppPending)
            .setVisibility(-1) // Notification.VISIBILITY_SECRET
            .setGroup("Lyrics_Notification")
            .setOngoing(false)
            .setColor(ColorUtils.getPrimaryColor(context))
            .setGroupSummary(false)
            .setShowWhen(false)
            .extend(new NotificationCompat.WearableExtender().addAction(wearableAction));

    if (notificationPref == 2) {
        notifBuilder.setOngoing(true).setPriority(-2); // Notification.PRIORITY_MIN
        wearableNotifBuilder.setPriority(-2);
    } else
        notifBuilder.setPriority(-1); // Notification.PRIORITY_LOW

    Notification notif = notifBuilder.build();
    Notification wearableNotif = wearableNotifBuilder.build();

    if (notificationPref == 2 || Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
        notif.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
    if (notificationPref == 1)
        notif.flags |= Notification.FLAG_AUTO_CANCEL;

    try {
        context.getPackageManager().getPackageInfo("com.google.android.wearable.app", PackageManager.GET_META_DATA);
        NotificationManagerCompat.from(context).notify(8, wearableNotif); // TODO Make Android Wear app
    } catch (PackageManager.NameNotFoundException ignored) {
    }

    return notif;
}