Вы можете создавать уведомления так же, как и в обычном режиме, не нужно делать ничего лишнего, например, ниже
public class ReceiveMessage extends BroadcastReceiver {
final SmsManager mysms = SmsManager.getDefault();
final String ALERT="A";
final String ALERT2="B";
public void onReceive (Context context, Intent intent) {
Bundle myBundle = intent.getExtras();
try {
if (myBundle != null) {
final Object [] pdus = (Object[])myBundle.get("pdus");
String format = myBundle.getString("format");
for (int i = 0; i < pdus.length ; i++) {
SmsMessage mynewsms= SmsMessage.createFromPdu((byte[]) pdus[i], format);
String sms = mynewsms.getMessageBody();
Toast.makeText(context, "SMS"+mynewsms, Toast.LENGTH_SHORT).show();
if (sms.equals(ALERT) {
Toast.makeText(context,"............",Toast.LENGTH_LONG).show();
showNotification(context,"Alert","............");
}
if (sms.equals(ALERT2) {
Toast.makeText(context,"Your child is out save zone",Toast.LENGTH_LONG).show();
showNotification(context,"Alert","Your child is out save zone");
}
}
}
} catch (Exception ex) {
}
}
}
public static void showNotification(Context context, String title, String msg) {
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Intent intent = new Intent();
PendingIntent pIntent = PendingIntent.getActivity(context, 2, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.BigTextStyle bigTextNotiStyle = null;
try {
bigTextNotiStyle = new NotificationCompat.BigTextStyle();
bigTextNotiStyle.setBigContentTitle(title);
bigTextNotiStyle.bigText("" + msg);
} catch (Exception e) {
e.printStackTrace();
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_noti_icon)
.setContentTitle("" + title)
.setContentText("" + msg)
.setStyle(bigTextNotiStyle)
.setAutoCancel(true)
.setColor(ContextCompat.getColor(context, R.color.staticbg))
.setContentIntent(pIntent)
.setLights(Color.GREEN, 3000, 3000);
mBuilder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
mBuilder.setSound(soundUri); //Sound to play
notificationManager.notify(2, mBuilder.build());
}