Can't Show Pop-Up on Android 13 and Below
So it is not possible to get a pop up on Android 12? I get this in the log and get directed to Notification Settings.
[ERROR ] [android_notify] On Android 12 and below Error checking permission: java/lang/Class is not an interface that can be instantiated with a callable
python : [WARNING] [android_notify]
python : Can't show popup below Android 13, Opening Notification setting...
python :
python : Add in MDApp().on_resume():
python : >> if NotificationHandler.has_permission() and self.screen_manager:
python : >> self.screen_manager.current = "home_screen"
python :
: [ERROR ] [android_notify] On Android 12 and below Error checking permission: java/lang/Class is not an interface that can be instantiated with a callable
python : [ERROR ] [android_notify] On Android 12 and below Error checking permission: java/lang/Class is not an interface that can be instantiated with a callable
python : [WARNING] [android_notify]
python : Can't show popup below Android 13, Opening Notification setting...
python : Add in MDApp().on_resume():
python : >> if NotificationHandler.has_permission() and self.screen_manager:
python : >> self.screen_manager.current = "home_screen"
python :
python : [ERROR ] [android_notify] On Android 12 and below Error checking permission: java/lang/Class is not an interface that can be instantiated with a callable
python : [WARNING] [android_notify] Permission not granted to send notifications
Will I have to use a lesser version of android-notify?
Hey @Nemesai38, No don't use the old versions, the new versions use a lazy loading technique to make sure the package takes 0 secs at app startup time and only initialize the java classes when needed, This feature caused the error:
java/lang/Class is not an interface that can be instantiated with a callable
pyjnius misinterprets it as a Python callable and fails, I'll push a fix for this bug shortly
@Nemesai38 Thanks for reporting this bug, I've pushed a new version 1.61.7 that supports the fix.
You can clear old versions by running
pip uninstall android-notify
pip install android-notify
android-notify prune
Then add a stable version by adding to requirements
requirements = android-notify
Regarding the second log, When i was testing on my Android 11 device, i found out android can't show runtime permission request popups on versions below 13, The only way to request permission on versions below 13 is by navigating to Settings.
So i added this Log as an helper, You can ignore it if you don't need to navigate to another screen after your User's Notification Response.
python : Can't show popup below Android 13, Opening Notification setting...
python :
python : Add in MDApp().on_resume():
python : >> if NotificationHandler.has_permission() and self.screen_manager:
python : >> self.screen_manager.current = "home_screen"
I tested the fix on Android 11. Let me know if the java/lang/Class is not an interface... error is gone on your side.
Cool!!, version 1.61.7 fixed it. Pop up comes up well now, and vibrate works well too. Logcat shows:
[WARNING] [android_notify] Already have permission to send notifications python : python : Sent Notification!!! python : python : title: Hello from KivyMD!! python : message: your custom image notification has arrived. python : channel_name: Default Channel, channel_id: shake python : big_picture_path: ./assets/imgs/red-cmddb-icon.png python : (Won't Print Logs When Complied,except if selected Notification.logs=True)
It's just the big picture doesn't show and the icon of the app at the top left that picks up by default(which works on Android 15 as i tested) also just shows a white blank circle on Android 12.
Nice, glad it works now.
The Big Picture and Icon displays on my Android 11 device,
Can i see a code snippet of how you call the methods and sample screenshots
Here's my test sample
n=Notification(
title="Hello from KivyMD!!",
message="your custom image notification has arrived."
)
n.setBigPicture("./assets/icons/bell.png")
n.send()
screenshot
- also What's your device model
Samsung,xiaomi,.. - is your png really transparent
- are you calling setLargeIcon together with
setBigPicture
Hey @Fector101, Sorry for the delay, was out of power. I using a Samsung A02s. Yes the png is transparent, its the same png i used for the setBigPicture that worked for the setLargeIcon and no i did not call them together. I tried setBigPicture first. This is my code snippet:
class MainScreen(MDScreen):
def send_notification(self):
try:
from android_notify import Notification
from android_notify import NotificationHandler
NotificationHandler.asks_permission()
Notification.createChannel(
id='shake',
name='Shake Passage',
vibrate=True
)
notification = Notification(
channel_id='shake',
title="Hello from KivyMD!!",
message="your custom image notification has arrived.",
logs=True,
)
notification.setLargeIcon("./assets/imgs/red-cmddb-icon.png")
notification.send()
print("Notification sent successfully!!")
except ImportError:
print("android_notify not found. Please install it.")
self.ids.status_label.text = "Notification module not available"
except Exception as e:
print(f"Error sending notification: {e}")
self.ids.status_label.text = f"Error: {str(e)}...."
Hey @Nemesai38, That's perfectly fine. Thanks for the details, they're really useful!
This actually narrows it down nicely:
setLargeIconworks andsetBigPicturedoesn't - the new problem is only in theBigPictureon Android 12, not permission or the image asset.- The white-blank-circle icon is the well-known
Android 12 small-icon behavior: notification header/status-bar icons are drawn from thealpha channel only, so the full-color app icon gets flattened into a white circle (Android 13+ sidesteps this with the adaptive icon's monochrome layer, which is why it looks fine on 15).
To reproduce and fix it, could you please:
- Open a new issue (this one was about the permission popup, which is already fixed in 1.61.7) Title it something like "BigPicture not showing + white blank small icon on Android 12".
- Attach the PNGs you're using, especially the
red-cmddb-icon.pngand yourapp icon, so I can reuse them for tests. - Put the device/Android version (Samsung A02s, Android 12) and your code snippet in the issue body.
- If possible a screenshot of the notification both collapsed and expanded.
Thanks!
Cool!! @Fector101 I have tried it again and yes the Big Picture shows only the app icon not showing. I will open the issue