java.lang.IllegalMonitorStateException:对象在notify()之前未被线程锁定
//我从sq lite数据库的数据处理程序类中获取数据java.lang.IllegalMonitorStateException:对象在notify()之前未被线程锁定,java,android,Java,Android,//我从sq lite数据库的数据处理程序类中获取数据 public class ReminderReciever extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm"); List<Reminder> reminderList; Date
public class ReminderReciever extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm");
List<Reminder> reminderList;
Date dateobj = new Date();
//我检查了所有其他课程,一切正常。在这里,它显示了一个错误,对象在通知前未锁定线程
alert.notify();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
if (alert == null) {
alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
}
Notification.Builder builder = new Notification.Builder(context);
NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
Notification myNotication;
builder.setSmallIcon(R.drawable.st);
builder.setContentTitle("SharedTasklist Notification");
builder.setTicker("SharedTasklist Reminder");
builder .setContentText("It's time to do " + taskName);
builder .setAutoCancel(true);
builder .setOngoing(true);
builder .setContentIntent(pendingIntent);
builder .setSound(alert); //This sets the sound to play
builder.build();
builder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
myNotication = builder.getNotification();
Random random = new Random();
int m = random.nextInt(9999 - 1000) + 1000;
manager.notify(m, myNotication);
alert.notify();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}