Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local notification crashes if app is removed from recent apps #1948

Closed
hristo-vrigazov opened this issue Nov 1, 2016 · 3 comments
Closed
Assignees
Milestone

Comments

@hristo-vrigazov
Copy link

Simple app to reproduce:

        Form hi = new Form("Hi World");
        Button button = new Button("Schedule notification");
        button.addActionListener(event -> {
            com.codename1.notifications.LocalNotification ln = new com.codename1.notifications.LocalNotification();
            ln.setId("LnMessage");
            ln.setAlertTitle("Welcome");
            ln.setAlertBody("Thanks for arriving!");
            ln.setBadgeNumber(1);
            Date date = new Date();
            date.setTime(date.getTime() + 4000);
            Display.getInstance().scheduleLocalNotification(ln, date.getTime(), com.codename1.notifications.LocalNotification.REPEAT_NONE);
        });
        hi.add(button);
        hi.show();

This triggers a notification 4 seconds after the button is clicked. When I run this on my Android device, it works fine if the app is in foreground or if it is in recent apps. However, when I remove it from recent apps, the local notification crashes.

@chen-fishbein
Copy link
Collaborator

can you please share the crash stacktrace

@hristo-vrigazov
Copy link
Author

Yes, of course, I forgot that.


14:03:34 E AndroidRuntime : FATAL EXCEPTION: main
14:03:34 E AndroidRuntime : Process: com.recipes.local, PID: 24390
14:03:34 E AndroidRuntime : java.lang.RuntimeException: Unable to start receiver com.codename1.impl.android.LocalNotificationPublisher: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
14:03:34 E AndroidRuntime : at android.app.ActivityThread.handleReceiver(ActivityThread.java:2732)
14:03:34 E AndroidRuntime : at android.app.ActivityThread.-wrap14(ActivityThread.java)
14:03:34 E AndroidRuntime : at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
14:03:34 E AndroidRuntime : at android.os.Handler.dispatchMessage(Handler.java:102)
14:03:34 E AndroidRuntime : at android.os.Looper.loop(Looper.java:148)
14:03:34 E AndroidRuntime : at android.app.ActivityThread.main(ActivityThread.java:5422)
14:03:34 E AndroidRuntime : at java.lang.reflect.Method.invoke(Native Method)
14:03:34 E AndroidRuntime : at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
14:03:34 E AndroidRuntime : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
14:03:34 E AndroidRuntime : Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
14:03:34 E AndroidRuntime : at com.codename1.impl.android.LocalNotificationPublisher.createAndroidNotification(LocalNotificationPublisher.java:90)
14:03:34 E AndroidRuntime : at com.codename1.impl.android.LocalNotificationPublisher.onReceive(LocalNotificationPublisher.java:76)
14:03:34 E AndroidRuntime : at android.app.ActivityThread.handleReceiver(ActivityThread.java:2725)
14:03:34 E AndroidRuntime : ... 8 more
14:03:34 E GMPM : getGoogleAppId failed with status: 10
14:03:34 E GMPM : Uploading is not possible. App measurement disabled
14:03:50 E QCALOG : [MessageQ] ProcessNewMessage: [LOWI-SERVER] unknown deliver target [OS-Agent]

@hristo-vrigazov
Copy link
Author

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants