I want to write reminder. What i need to use? Make service app or just standart app runing in background or another way?
Thanks for replys!
What I really liked about this question is you asked about the idea for the app that you want to implement. You didn't ask for code.
I would suggest that you should make an app which should have a broadcast receiver, but still it should have service that runs in background.
The service will check the current time with your reminder time. A broadcast receiver is required to listen to startup broadcast, because you need to start your app as soon as your handset starts.
Have a look at this.
Have a look at the AlarmManager. It allows you to schedule your application to be run at some point in the future.
Related
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.
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.
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.
One is to use the START_STICKY flag. It's implemented in python-for-android, but it seems broken to me.
Another one is to use the a recent feature, setAutoRestartService(). It will make the service restart itself gracefully/programmatically on kill.
Bonus way use a BroadcastReceiver, but this is not implemented in p4a.
I have some doubts about the properly implementation of services and broadcastreceivers.
I have made an app in which there are novelties. Some novelties are important, so in the DB they have a field in which they store if they are important or not. If they are, the app should check if the last novelty seen by the user is the latest one. This should trigger a notification if there are important novelties that were not seen by the user.
I know how to show notifications in Android, and I have a Method in my Web Service which shows if the user has novelties to read or not. I just need to know how to make my app consume this at random times and without being opened (just like Whatsapp does).
I have read the BroadcastReceiver and Services documentation, but I don't know how to do this in an efficient way.
Do I make a BroadcastReceiver to call a Service at the Phone's Boot? And make this Service to check at random amounts of time?
Thanks a lot!
What you want is a foreground service with a BroadcastReceiver that starts the service on boot. View this answer and make the required changes to use startForeground() instead of startService.
I want to fetch the current Location of the user in background. I know how it can be done using Service in Android. But I would like to know is there any possibilities to get user Location without running service. Like using BroadcastReceiver or anything? I'm just trying to avoid running Service to fetch Location.
For Example I referred this link. But I couldn't follow how to do like this.
Any help will be appreciated. Correct me in case I'm asking anything wrong.
EDIT: Oh, I think in the above link he is using Service to get the Location. So I think it's not possible to get location in background without running a Service. Still suggestions are welcomed.
You Should Implement a BroadcastReceiver that receives alarm every 2 hours. That alarm is Set by Your Activity.
When the alarm is triggered by your System, Broadcast Receiver receives it, Executes Your Process in BroadCastReceiver.
This is what i can think of.
I came in to scenario that I want to trigger service on specific time.
What I Know is...
I need use AlarmManager, and I found this question in hear, Using Alarmmanager to start a service at specific time. Now, I am able to start service on specific time.
Now question I have is... I need 24H interval to start service. now What happens if the phone restart. Is it going to start service again?
How can I make this thing happen?
Please help me with this
Thank you
No.. It wont.. You need to set it again when phone Boots .. something like this
You'll need to register a BroadcastReceiver that can receive the BOOT_COMPLETED message so it receives a message when the phone reboots...
Read this article!
http://karanbalkar.com/2013/07/tutorial-41-using-alarmmanager-and-broadcastreceiver-in-android/
I am having some design techniques about How shall I schedule a code to retrieve the weather info?
Should I use alarms to retrieve the weather each 10 minutes?
And do I need to run a service for this? Or just put the code in the Broadcastreceiver and start when the alarm fired?
This is a good question. Yes, you will need to put this code in either a service or broadcastreceiver because when and activity loses focus (meaning the user is using a different app or the phone is asleep) they pause and/or close. However, i have no experience with either Services or Broadcastrecievers, so that is as much as i can tell you.