[Python] FLAG_IMMUTABLE or FLAG MUTABLE in notification kivy for android

Discussão em 'Python' iniciado por Stack, Fevereiro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have a simple code that show a notification using the plyer.

    from kivy.app import App
    from kivy.lang import Builder
    from kivy.utils import platform
    from plyer import notification
    from kivy.uix.boxlayout import BoxLayout
    from kivy.clock import Clock
    from kivy.properties import DictProperty
    from kivy.uix.label import Label

    Builder.load_string("""
    <NotificationDemo>:
    BoxLayout:
    Label:
    id: notification_text
    text: 'Hi user'
    font_size:50

    """)
    a=0
    class NotificationDemo(BoxLayout):
    kwargs = DictProperty()
    def update(self,dt):
    global a
    try:
    a = a + 1
    sms = str(a)
    self.ids.notification_text.text = sms
    notification.notify(title='hello' , message=sms)
    except Exception as error:
    self.ids.notification_text.text = str(error)

    class ServiceApp(App):
    def build(self):
    fdir = NotificationDemo()
    Clock.schedule_interval(fdir.update, 6)
    return fdir

    def on_pause(self):
    return True

    if __name__ == '__main__':
    ServiceApp().run()



    This code work correctly on Windows and low Androids. But when I run this code on Android 13 I get the following error.


    JVM exception occurred : org.test.notify : 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 . java.lang.IllegalArgumentException
    ​

    I have seen similar questions here and here but they have no answers. Should I use the service? Or should I do something in the buildozer.spec? I really appreciate any help you can provide.

    Continue reading...

Compartilhe esta Página