|
@@ -1,6 +1,7 @@
|
|
|
package com.hola;
|
|
package com.hola;
|
|
|
|
|
|
|
|
import android.app.NotificationManager;
|
|
import android.app.NotificationManager;
|
|
|
|
|
+import android.app.PendingIntent;
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.BroadcastReceiver;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
@@ -19,12 +20,15 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
String title = intent.getStringExtra("title");
|
|
String title = intent.getStringExtra("title");
|
|
|
String message = intent.getStringExtra("message");
|
|
String message = intent.getStringExtra("message");
|
|
|
String channel = intent.getStringExtra("channel");
|
|
String channel = intent.getStringExtra("channel");
|
|
|
|
|
+
|
|
|
|
|
+ PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent,0);
|
|
|
// 创建通知构建器
|
|
// 创建通知构建器
|
|
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channel)
|
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channel)
|
|
|
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
|
.setContentTitle(title)
|
|
.setContentTitle(title)
|
|
|
.setContentText(message)
|
|
.setContentText(message)
|
|
|
- .setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
|
|
|
|
|
|
+ .setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
|
|
|
+ .setContentIntent(pendingIntent);
|
|
|
|
|
|
|
|
// 显示通知
|
|
// 显示通知
|
|
|
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
|
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|