Я работаю над музыкальным приложением для Android, пытаюсь изменить TextView
и цвета значков на светлой строке состояния на черный, а на темной строке состояния - на белый (как в Instagram), но я не могу сделать это. Было несколько способов проверить версию Android, но это мне не помогло. Я должен проверить тему, я думаю. Во всяком случае, что я должен делать?
Вот распечатка экрана уведомления
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
return useWhiteIcon ? R.layout.layout_notification_small: R.layout.layout_notification_small_black;
}
public void showNotification() {
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
String CHANNEL_ID = "controls_channel_id";
String CHANNEL_NAME = "controls_channel";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
channel.setSound(null,null);
channel.enableVibration(false);
notificationManager.createNotificationChannel(channel);
notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setChannelId(CHANNEL_ID)
.setContentText("placeholder")
.setContentTitle("placeholder");
}else{
notificationBuilder = new NotificationCompat.Builder(
getApplicationContext());
}
Track track = tracks.get(trackIndex);
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.layout_notification);
remoteViews.setTextViewText(R.id.tvTitle, track.getTitle());
RemoteViews remoteSmallViews= new RemoteViews(getPackageName(),getNotificationIcon());
remoteSmallViews.setTextViewText(R.id.tvTitle, track.getTitle());