Forum > Android

AppNotificationManagerDemo1 crashes when running on android13 (solved)

(1/2) > >>

iwizard:
I compiled and ran AppNotificationManagerDemo1, unfortunately, my attempt failed under android13, the program crashed after clicking the Push System Notification button, but my phone using android4.1 also ran successfully, what is the reason, how do I need to troubleshoot and solve the problem?

marcos-ebm:
[using the translator]

From what I've noticed, it doesn't work on new phones because of the appcompat theme.

on old smartphones, it works with the default theme (deviceDefault)

I believe the NotificationManager component is not updated to use appCompat

marcos-ebm:
[using the translator]

The component is working perfectly, there is something in the Demo that is bad, but as it is a Demo, it is better not to use it

do it like this

Create a new project, add only the NotificationManager1 component to the form

create a button and place the code in the button's onClick


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TAndroidModule1.Button1Click(Sender: TObject);begin   NotificationManager1.Notify();end;
try it



It's better to use the Demos just to see the codes

As the Lamw project changed over time, the Demos didn't keep up, but over time everything got better.

iwizard:
Thanks for the reply, I created a new project, put a button and a jNotificationManager control on it, wrote the code in the click event of the button NotificationManager1.Notify(); No error is reported when the execution is executed, but the Notify message does not appear. :(

In addition, I found that the crash in the demo problem was not caused by jNotificationManager, but by jIntentManager, which was caused by jNotificationManager1.SetContentIntent(......) Comment out, demo does not report error under android13, but again, the notify notification message does not appear after the code is executed.

Insid3Code:
Hi,
It related to missing required flag for PendingIntent.

EXCEPTION MSG:

--- Quote ---called with pending exception java.lang.IllegalArgumentException:
com.example.appnotificationmanagerdemo1: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable,
e.g. if it needs to be used with inline replies or bubbles.
--- End quote ---

GAIN NOTIFICATIONS PERMISSION:
1- manifest side:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
2- use runtime permission call to ask user.

See animated gif:
https://i.imgur.com/aDPkQOC.gif

Navigation

[0] Message Index

[#] Next page

Go to full version