Skip to content

Commit 599702c

Browse files
onReceives() causes java.lang.IllegalStateException ? #154
1 parent 0ad56c4 commit 599702c

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

demo/nsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"useLegacyWorkflow": true
3+
}

native-src/android/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
## Building the framework
44
- Import this folder as a gradle project in Android Studio
55
- Change anything needed
6-
- In the Gradle build window run app > build > build
7-
- Grab the release .aar from native-src/android/app/build/outputs/aar: `cp native-src/android/app/build/outputs/aar/app-release.aar src/platforms/android/`
6+
- In the Gradle build window run `app > build > clean` and `app > build > build`
7+
- Copy the release .aar: `cp native-src/android/app/build/outputs/aar/app-release.aar src/platforms/android/`

native-src/android/app/app.iml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<option name="ALLOW_USER_CONFIGURATION" value="false" />
1818
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
1919
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
20-
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
20+
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
2121
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
2222
<option name="PROJECT_TYPE" value="1" />
2323
</configuration>
@@ -95,7 +95,6 @@
9595
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
9696
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
9797
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
98-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
9998
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
10099
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
101100
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />

native-src/android/app/src/main/java/com/telerik/localnotifications/NotificationClearedReceiver.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ public void onReceive(Context context, @Nullable Intent intent) {
2727
final int id = intent.getIntExtra(Builder.NOTIFICATION_ID, 0);
2828
final JSONObject opts = Store.get(context, id);
2929

30-
if (opts.optInt("repeatInterval", 0) == 0) {
31-
// Remove the persisted notification data if it's not repeating:
32-
Store.remove(context, id);
33-
}
30+
if (opts != null) {
31+
if (opts.optInt("repeatInterval", 0) == 0) {
32+
// Remove the persisted notification data if it's not repeating:
33+
Store.remove(context, id);
34+
}
3435

35-
LocalNotificationsPlugin.executeOnMessageClearedCallback(opts);
36+
LocalNotificationsPlugin.executeOnMessageClearedCallback(opts);
37+
}
3638
}
3739
}

native-src/android/app/src/main/java/com/telerik/localnotifications/NotificationRestoreReceiver.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ public void onReceive(Context context, Intent intent) {
2828
return;
2929
}
3030

31-
for (Map.Entry<String, String> entry : Store.getAll(context).entrySet()) {
32-
final String notificationString = entry.getValue();
31+
try {
32+
for (Map.Entry<String, String> entry : Store.getAll(context).entrySet()) {
33+
final String notificationString = entry.getValue();
3334

34-
Log.e(TAG, "Will restore previously scheduled notification: " + notificationString);
35+
Log.e(TAG, "Will restore previously scheduled notification: " + notificationString);
3536

36-
try {
3737
scheduleNotification(new JSONObject(notificationString), context);
38-
} catch (JSONException e) {
39-
Log.e(TAG, "Notification could not be scheduled! " + e.getMessage(), e);
4038
}
39+
} catch (IllegalStateException | JSONException e) {
40+
Log.e(TAG, "Notification could not be scheduled! " + e.getMessage(), e);
4141
}
4242
}
4343

-135 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)