不要な比較を削除(アプリの要求APIバージョンがもともと26(=8.0(=Oreo))のため)

This commit is contained in:
ろむねこ 2024-07-11 14:22:28 +09:00
parent 6ef2c129c6
commit d723165b76
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -181,22 +181,20 @@ public class TestService extends Service {
.setPriority(NotificationCompat.PRIORITY_HIGH) // プライオリティを高く設定 .setPriority(NotificationCompat.PRIORITY_HIGH) // プライオリティを高く設定
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); // ロック画面に表示する .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); // ロック画面に表示する
// NotificationChannelの作成Android 8.0以降 // 通知チャンネルの作成
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
NotificationManager notificationManager = context.getSystemService(NotificationManager.class); if (notificationManager != null) {
if (notificationManager != null) { NotificationChannel channel = new NotificationChannel(
NotificationChannel channel = new NotificationChannel( CHANNEL_ID,
CHANNEL_ID, "Channel Name",
"Channel Name", NotificationManager.IMPORTANCE_HIGH
NotificationManager.IMPORTANCE_HIGH );
);
channel.setDescription("Channel Description"); channel.setDescription("Channel Description");
channel.enableLights(true); channel.enableLights(true);
channel.setLightColor(Color.RED); channel.setLightColor(Color.RED);
channel.enableVibration(true); channel.enableVibration(true);
notificationManager.createNotificationChannel(channel); notificationManager.createNotificationChannel(channel);
}
} }