我正在尝试在Android Studio中使用通知发出警报,我尝试this link,但出现错误“强制关闭”。 Log Cat中没有错误消息。请帮助我找到这个问题。我完整的代码My Complete Code is here。
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());
}
}
答案 0 :(得分:0)
我想您尚未在AndroidManifest.xml中包含广播接收器
<receiver
android:name="MyAlarm" >
</receiver>