FATAL EXCEPTION: MQTT Rec: device_001
Process: org.eclipse.paho.android.sample, PID: 20594
java.lang.SecurityException: Caller org.eclipse.paho.android.sample needs to hold android.permission.SCHEDULE_EXACT_ALARM to set exact alarms.
at android.os.Parcel.createExceptionOrNull(Parcel.java:2426)
at android.os.Parcel.createException(Parcel.java:2410)
at android.os.Parcel.readException(Parcel.java:2393)
at android.os.Parcel.readException(Parcel.java:2335)
at android.app.IAlarmManager$Stub$Proxy.set(IAlarmManager.java:393)
at android.app.AlarmManager.setImpl(AlarmManager.java:957)
at android.app.AlarmManager.setImpl(AlarmManager.java:917)
at android.app.AlarmManager.setExactAndAllowWhileIdle(AlarmManager.java:1185)
at org.eclipse.paho.android.service.AlarmPingSender.schedule(AlarmPingSender.java:126)
at org.eclipse.paho.android.service.AlarmPingSender.start(AlarmPingSender.java:90)
at org.eclipse.paho.client.mqttv3.internal.ClientState.connected(ClientState.java:1214)
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:1050)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:151)
at java.lang.Thread.run(Thread.java:920)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.alarm.AlarmManagerService$5.set(AlarmManagerService.java:2594)
at android.app.IAlarmManager$Stub.onTransact(IAlarmManager.java:210)
at android.os.Binder.execTransactInternal(Binder.java:1182)
at android.os.Binder.execTransact(Binder.java:1146)
需要加上下面权限
参考文档: https://stackoverflow.com/questions/71031091/android-12-using-schedule-exact-alarm-permission-to-get-show-data-at-specific-t
报错信息如下:
FATAL EXCEPTION: MQTT Rec: device_001 Process: org.eclipse.paho.android.sample, PID: 20594 java.lang.SecurityException: Caller org.eclipse.paho.android.sample needs to hold android.permission.SCHEDULE_EXACT_ALARM to set exact alarms. at android.os.Parcel.createExceptionOrNull(Parcel.java:2426) at android.os.Parcel.createException(Parcel.java:2410) at android.os.Parcel.readException(Parcel.java:2393) at android.os.Parcel.readException(Parcel.java:2335) at android.app.IAlarmManager$Stub$Proxy.set(IAlarmManager.java:393) at android.app.AlarmManager.setImpl(AlarmManager.java:957) at android.app.AlarmManager.setImpl(AlarmManager.java:917) at android.app.AlarmManager.setExactAndAllowWhileIdle(AlarmManager.java:1185) at org.eclipse.paho.android.service.AlarmPingSender.schedule(AlarmPingSender.java:126) at org.eclipse.paho.android.service.AlarmPingSender.start(AlarmPingSender.java:90) at org.eclipse.paho.client.mqttv3.internal.ClientState.connected(ClientState.java:1214) at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:1050) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:151) at java.lang.Thread.run(Thread.java:920) Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.alarm.AlarmManagerService$5.set(AlarmManagerService.java:2594) at android.app.IAlarmManager$Stub.onTransact(IAlarmManager.java:210) at android.os.Binder.execTransactInternal(Binder.java:1182) at android.os.Binder.execTransact(Binder.java:1146)