13

I am writing a python app in kivy.

The idea is to allow the user to make notes of bookings for certain dates, and then the program should send them a notification on that day about the booking.

There's probably a simple way to do this, I am using plyer.

from plyer import notification
notification.notify(title="Kivy Notification",message="Plyer Up and Running!",app_name="Waentjies",app_icon="icon.png",timeout=10)

This works, I get a notification whenever I call that function, however, I can't find any way to send this notification while the app is not running, I do know that there are some other questions that seem to answer this question, but they don't, their simply to run a app in background, which I don't want to do, all I want is something like Clash of Clans notification when your troops are ready for battle, or Facebook's notification when somebody liked your post.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Cid-El
  • 500
  • 7
  • 30

2 Answers2

1

I think you should take a look at the Android AlarmManager. If this is what you need, here is an example for Kivy.

AlarmManager

This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future. When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running.

Community
  • 1
  • 1
WJVDP
  • 62
  • 5
  • Thanks for answering Willem, however when i package that code the program crashes, I've browsed some and somewhere i found another question exactly like this, and the answer was that this is not possible, I am very sorry for it, but I've talked to my client and we worked a way around it for the app, so for myself this is no longer needed, it would have been nice though, but its needles for me to spend more time on it now, maybe later. Thanks for sharing your knowledge! – Cid-El Aug 29 '16 at 12:56
  • 1
    I know this is very late, but is there another working version of the link to a Kivy example? – SomeMosa May 22 '19 at 21:59
0

On Android, I'm not sure how I would implement it without a background service.

The thing with background services is they also get killed when the application that started the process gets killed. I know 2-3 ways to prevent that on Android, I consider it hack, but maybe it's a feature.

  1. One is to use the START_STICKY flag. It's implemented in python-for-android, but it seems broken to me.

  2. Another one is to use the a recent feature, setAutoRestartService(). It will make the service restart itself gracefully/programmatically on kill.

  3. Bonus way use a BroadcastReceiver, but this is not implemented in p4a.

Andre Miras
  • 3,580
  • 44
  • 47