Repository navigation
Improvements
- Dynamic broadcast buttons:
addButton(..., action=..., dynamic=True)sends a package-scoped broadcast to a runtimeBroadcastReceiver, so a button can act from a service without a manifest receiver or Java class. MediaNotification.setNowPlaying(title, artist)updates the live notification and lock-screen metadata in one call on a track change.- Media notification module moved to
android_notify.media. SoundLoaderandMediaPermissionHandlerstay under android_notify.media.music. - Plain controllers that do not dispatch events can drive the notification with
syncPlaybackState(). - Media artwork now falls back to the app icon when a track has no embedded cover art.
- Faster path and playback handling: removed the slow android.storage import from the notification path and optimized media position/length reads.
Changed
- Removed the run_on_ui_thread helper. Open activities from the UI thread directly; do not ask permissions from a background thread.
- Button
PendingIntentrequest codes are unique per notification, so two notifications with the same button action no longer overwrite each other's extras.
Fixed
- Unknown media length no longer raises while the notification is being updated.
- Media metadata and artwork refresh on a track change without waiting for the next playback event.
Pull Requests
- refactor(music): route media notifications through a media controller by @Fector101 in #68
- Feat/plain media controller by @Fector101 in #71
- Dynamic BroadcastReciver Buttons - No Java by @Fector101 in #73
- Performance improvement Aimed at Older Devices by @Fector101 in #74
Full Changelog: v1.61.10...v1.62.0
Snippet
Dynamic Broadcast Receiver - Make your buttons take actions without opening App, Useful for Foreground Services.
from android.broadcast import BroadcastReceiver
from android_notify import Notification
from android_notify.config import get_package_name
package = get_package_name() # package.domain + "." + package.name
# Recieves Broadcast on Button Click
def on_broadcast(context, intent):
action = intent.getAction()
print(f"BroadcastReceiver: action={action}, extras={intent.getExtras()}")
# BroadcastReceiver: action=org.test.myapp.ACTION_SKIP, extras=...)
notification.updateMessage(action)
# Keep a reference, an unreferenced receiver can be collected and stop delivering.
receiver = BroadcastReceiver(on_broadcast, actions=[package + '.ACTION_STOP', package + '.ACTION_SKIP'])
receiver.start()
# Sends BroadCast on Button Click
notification = Notification(title="Broadcast test")
notification.addButton("Stop", action=package + ".ACTION_STOP", dynamic=True)
notification.addButton("Skip", action=package + ".ACTION_SKIP", dynamic=True)
notification.send()