前提・実現したいこと
該当のソースコード
java
1 //アラーム通知チャンネル使用 2 String channelId = "alarm"; 3 Intent fullScreenIntent = new Intent(intent2); 4 PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, 0, 5 fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT); 6 7 NotificationCompat.Builder notificationBuilder = 8 new NotificationCompat.Builder(this, channelId) 9 .setSmallIcon(R.mipmap.ic_launcher_round) 10 .setContentTitle(getString(R.string.app_name)) 11 .setContentText(notifyMsg) 12 .addAction(0, "停止画面を開く", fullScreenPendingIntent) 13 .setFullScreenIntent(fullScreenPendingIntent, true); 14 15 //***/>以下は停止画面が開いてないときのみ設定するように!! 16 notificationBuilder.addAction(0, "スヌーズ", fullScreenPendingIntent); 17 18 notification = notificationBuilder.build(); 19 20 // startForeground 21 startForeground(1, notification);
補足情報(FW/ツールのバージョンなど)
Android Studio3.4
APIレベル14から28まで対象
あなたの回答
tips
プレビュー