我正在尝试在 Android Studio 中使用通知发出警报,我尝试使用此链接,但出现错误“强制关闭”。Log Cat 中没有错误消息。请帮我找到这个问题。我的完整代码我的完整代码在这里。
public class MyAlarm extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("Mine", "Set Daily");
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notifications_white)
.setContentTitle("My notification")
.setContentText("Hello World!");
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(001, mBuilder.build());
}
}