TestServiceの全体的なリファクタリング #28
|  | @ -181,8 +181,7 @@ 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( | ||||||
|  | @ -197,7 +196,6 @@ public class TestService extends Service { | ||||||
|             channel.enableVibration(true); |             channel.enableVibration(true); | ||||||
|             notificationManager.createNotificationChannel(channel); |             notificationManager.createNotificationChannel(channel); | ||||||
|         } |         } | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|         NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); |         NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user