1

EDITED: I believe this question is NOT a duplicate of other questions since it applies specifically to CodenameOne , and how it uses the android libraries, not just to the android libraries themselves. I believe that either a) I need help in how to use the CodenameOne classes correctly, or b) the CodenameOne classes needs to be updated to work with Android 5.1.1.

The problem: When I use 'scheduleLocalNotification' with CodenameOne compiled to Android, the notification works but the message contains only white squares where I would expect the application icon. My test code is very like that in the documentation for Class LocalNotification in codenameone:

LocalNotification n = new LocalNotification();
n.setId("LnMessage");
n.setAlertTitle("Alert Title");
n.setAlertBody("Alert detailed message");
Display.getInstance().scheduleLocalNotification(
  n, System.currentTimeMillis()+10, LocalNotification.REPEAT_NONE
);

Full example: https://gist.github.com/twilkinson/893d96bcf84698e0c694775b99174460

Here are a couple of screen shots from the Android device that illustrate my problem.

Image 1

image 1

Image 2

image 2

I've tried placing an image file alert-image.png in the project beside theme.res and adding the line

n.setAlertImage("alert-image.png");

but that doesn't seem to help.

My device is a Nexus 4 with Android version 5.1.1

Can someone point me to an example somewhere of how to make this work?

UPDATED: At Shai's suggestion (below), I added an image file ic_stat_notify.png to the native/android folder (white on transparency). The result was no change to the notification area image ("Image 1" above), but the new image showed in the expanded notification drawer ("Image 3" below).

Image 3

image 3

Terry Wilkinson
  • 157
  • 1
  • 8
  • 1
    Place a 24x24 icon named `ic_stat_notify.png` under the `native/android` folder of the app. The icon can be white with transparency areas. The build server picks up this image and uses it as the notification icon if found on the project. – Shai Almog Mar 20 '17 at 05:15
  • Shai, thanks, that got me part of the way. The ic_stat_notify.png image now shows up in the expanded notification message (2nd image above) but not in the status bar (1st image above). I looked at the source code for createAndroidNotification() in impl/android/LocalNotificationPublisher.java on github, and it looks like it should work, but I'm still getting the white square in the status bar. – Terry Wilkinson Mar 20 '17 at 15:30
  • Can you update the screenshots, I'll have to check on that – Shai Almog Mar 21 '17 at 04:54
  • I've looked into it a bit and it seems the behavior is a bit problematic, can you please file an issue in git? – Shai Almog Mar 21 '17 at 08:46
  • I've updated the OP and filed a github Issue (#2068). Thanks. – Terry Wilkinson Mar 21 '17 at 19:49
  • That's the exact opposite of what I understood, I thought the titlebar one was fixed – Shai Almog Mar 22 '17 at 05:08
  • Sorry, I didn't know/use the correct terminology in my comment - I think I got it right when I updated the OP. (https://developer.android.com/guide/topics/ui/notifiers/notifications.html) – Terry Wilkinson Mar 22 '17 at 12:40
  • It's very possible you did use the right terminology, it's just that an image is much clearer ;-) – Shai Almog Mar 23 '17 at 05:11

0 Answers0