|
|
@@ -39,6 +39,7 @@ import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.time.LocalTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.List;
|
|
|
@@ -131,6 +132,25 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
if (getCurrentActivity()==null){
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ //取消历史alarm
|
|
|
+ List<PendingIntent> allPendingIntents = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ int requestCode = i;
|
|
|
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(getCurrentActivity(), requestCode, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
+ if (pendingIntent != null) {
|
|
|
+ allPendingIntents.add(pendingIntent);
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
|
|
|
+ for (PendingIntent pendingIntent : allPendingIntents) {
|
|
|
+ alarmManager.cancel(pendingIntent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
try {
|
|
|
JSONArray jsonArray = new JSONArray(jsonData);
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
@@ -155,7 +175,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(
|
|
|
getCurrentActivity(), i, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
- AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
|
|
|
+// AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
|
AlarmManager.AlarmClockInfo info = alarmManager.getNextAlarmClock();
|
|
|
if (info!=null){
|