LAMW - LAz4Android Android JNotificationManager lazarus / 43-Android ---------------------------------------------------------------------- freris · 2016-05-13 06:31 Hi to all Next compatibility problem for LAMW is the JNotificationManager component that causes application crash in api's below 19. I found that solution: Step 1:  Add to folder /libs the android-support-v4.jar  file Step 2:  In Controls.java (folder yourapp/src/yourorg/yourproject/) Add in import section this:  import android.support.v4.app.NotificationCompat; Step 3: in same file as step 2 change the line Notification notif = new Notification.Builder(controls.activity) with: Notification notif = new NotificationCompat.Builder(controls.activity) and compile / make apk / install on devices with api below 19 no more crashes I hope that jmpessoa, will fix the problem in his own way. Have a good day ---------------------------------------------------------------------- jmpessoa · 2016-05-14 03:26 Hi freris, I think your solution is need  only when  you are:  1. targeting API  <  11    (Android 3.0/API 11)  2. Using manifest minSKD < 11 ---------------------------------------------------------------------- freris · 2016-05-14 08:23 Hi jmpessoa! Yes of course , you are right. Thank you for answer. Regards - freris ---------------------------------------------------------------------- freris · 2016-05-17 10:16 Hellow jmpessoa! I found another addition for JNotificationManager In Controls.java adding this line: .setLights(Color.BLUE, 500, 500) between the lines: public void Notify(int _id, String _title, String _subject, String _body, String _iconIdentifier){ ----------------- -----------------        .setSmallIcon(icon)   -->> .setLights(Color.BLUE, 500, 500) <<-----        .build();     the Blue led lights every 500ms if screen is locked I hope  to include this improvement in future versions of LAMW and if is possible, to set 3 new parameters to JNotificationManager properties such as "Led color"  = (BLUE-GREEN-RED) "Flashing time" (ms xxx) "Led notification enable" (True - False) Greetings from freris ---------------------------------------------------------------------- freris · 2016-05-17 11:40 Just found this article for problems with JNotificationManager on Api below 16 http://stackoverflow.com/questions/22176761/how-to-call-notification- builder-build-on-device-with-api-15 --> Builder.build() is available since API level 16. Use the approach below to create a notification. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i @SuppressLint("NewApi")@SuppressWarnings("deprecation")public static Notification build(final Builder builder) {    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {        return builder.build();    } else {        return builder.getNotification(); // <--------- critical    }}  So i make a test without using (import android.support.v4.app.NotificationCompat;) I change this line in my application -> Controls.java ------------ ------------ .build(); mNotificationManager.notify(_id, notif);          with: ------------ ------------     .getNotification();       mNotificationManager.notify(_id, notif); or more functional Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         else           icon = GetDrawableResourceId(_iconIdentifier) ;        ----------   ------- -------        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {       mNotificationManager=(Notifica tionManager)controls.activity.getSystemService(Context.NOTIFICATION_SE RVICE);             Notification notif = new Notification.Builder(controls.activity)          .setContentTitle(_title)               .setContentText(_subject)     .setContentInfo(_body)       .setSmallIcon(icon)        .setLights(Color.BLUE, 1000, 1000)                  .build();       mNotificationManager.notify(_id, notif);    } else {                m NotificationManager=(NotificationManager)controls.activity.getSystemSe rvice(Context.NOTIFICATION_SERVICE);            Notification notif = new Notification.Builder(controls.activity)          .setContentTitle(_title)               .setContentText(_subject)     .setContentInfo(_body)       .setSmallIcon(icon)        .setLights(Color.BLUE, 1000, 1000)                  .getNotification();       mNotificationManager.notify(_id, notif);  }}  and no more crashes on my emulator (Api 15) ---------------------------------------------------------------------- jmpessoa · 2016-05-17 16:29 Hi freris! I will make the changes [and additions] that you has proposed! Thank you! ---------------------------------------------------------------------- freris · 2016-05-17 17:26 Hi jmpessoa! As a retiree, I have too much time and I like to try and improve. Especially in such a fantastic job that you have done. Have a nice day. ---------------------------------------------------------------------- freris · 2016-05-21 13:30 Hi jmpessoa! I saw the changes that you has made and is perfect now. Except one small problem. If set a color, a color from pallette , e.g. colbrGreen or every other color, always the light is blue. I suppose that these colors is not compatible with android notification colors. Is it true, or something else happens ? Thanks - freris ---------------------------------------------------------------------- jmpessoa · 2016-05-21 22:15 Quote... or something else happens ? Yes! Fixed!  ref. "version 0.6 - revision 45.1 - 21 May - 2016" Thank you! ---------------------------------------------------------------------- freris · 2016-05-22 08:18 Hi jmpessoa! Yes, it is ok except green light (blue - red ok) For Green i try : colbrGreen , colbrLimeGreen , colbrLime and all other xx-green colors and some times i saw pink color or no color - no blink. Thanks - freris (Edit) Sorry, my fault. My phone (an old Sony) not have real RGB led. All IS OK - Thank you