Skip to content

Bakterija/android-notification-buttons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Android Notification Builder for Python

Requires Kivy and Plyer, use Buildozer to build android apks

Provides a simple way of building Android notifications with buttons with callbacks, no java knowledge required.
Buttons allow you to control your background services while using other apps

screenshot

How to use

Copy "noti_builder" folder to "service/" folder

Import

from noti_builder.noti_builder import Notification_Builder

Instantiate

nBuilder = Notification_Builder()

Set title, message, ticker

nBuilder.set_title('myTitle')
nBuilder.set_message('myMessage')
nBuilder.set_ticker('Button example')

Add subtext, if required

nBuilder.set_subtext(str)

Add buttons, if required

## 0. Displayed button name
## 1. icon integer available at https://developer.android.com/reference/android/R.drawable.html
## 2. callback
## action= android PendingIntent action, button name will be used if not provided
nBuilder.add_button('Play', 17301540 , callback, action='Play')

Build

nBuilder.build()

More functions, use before .build()

Add vibration (seconds)

nBuilder.set_vibrate(float)

Add sound (path)

nBuilder.set_sound(str)

Change intent name

### Default is "org.renpy.android.ACTION_"
### Buttons broadcast "intent name"+"button action",
### for example, Play button broadcasts "org.renpy.android.ACTION_Play"
nBuilder.set_intentName(str)

Remove notification

nBuilder.remove_notification()
nBuilder.javaBuilder
### For example, nBuilder.javaBuilder.setOngoing(True) will make notification ongoing
### Remember that javaBuilder is reset when nBuilder.build is called

Remove buttons

nBuilder.remove_buttons()

Make unremovable

nBuilder.set_ongoing(True)

Remove on touch

nBuilder.set_autocancel(True)

BroadcastReceivers

nBuilder creates BroadcastReceivers when buttons are added to listen for touches,
Start/stop and get object list with

nBuilder.start()
nBuilder.stop()

nBuilder.get_receivers()
### BroadcastReceivers have start/stop methods,
### control them directly by getting the list and running BroadcastReceiver methods

About

Android Notification Builder for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages