-1

我正在尝试在 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());
    }
}
4

1 回答 1

0

我猜你没有在 AndroidManifest.xml 中包含广播接收器

<receiver 
    android:name="MyAlarm" >
</receiver>
于 2018-07-23T06:29:42.137 回答