I am newbie to android and just can do small simple tasks with android. Now i am trying to learn a bit harder things.
I want to build an application just like to-do task manager. In which i want to include feature of setting reminder for every particular task, the rest i would be able to handle. Can anyone please guide me or provide me tutorial for setting reminder. I think this includes a background service which constantly monitors the time and date, for a particular event to occur, and when that time and date matches to the task in the application it popups a reminder. Also, this service should start automatically even after restarting the phone. Please someone can guide me through if my direction of thinking is somewhat correct...
You may use AlarmManager and BroadCastReceiver that receives your alarm.
Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running.
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.
As a requirement in Android OS phone, I am developing an app which will clean up a particular folder in a specified interval of time, say every 30 minutes.
I have tried this using services, check my other posting stackoverflow: file-cleaning-service
I am trying to find a best method to execute the file cleaning operation.
Should I use a service with broadcasting (or a Handler)?
Should I perform it within the app without using a service? The app can hide itself and perform task in the background. Is this approach is good? My point is why should I use a service if the service is just sleeping for a specified time, why same cannot be achieved in the app itself?
Is there any other method through which I can achieve this?
I do not want to wake up the screen, hence I do not want to use AlarmManager.
So please help me with best solution. Thanks in advance.
Situation: We have more than 5 android applications which are modular (and really limited in terms of functionality) and each has it's own IntentService in which it gets data from internet and stores it locally.
Also one app is core/main app. Now I want, that each app updates its data during the night. I don't want to put code for alarm, receiver and other stuff into every app. I want that core app sets Alarm, and when alarm goes off, then core app calls all IntentServices of every app.
Question: How can I prevent that system goes to sleep during the execution of services?
One solution is that I use #CommonsWare implementation of WakefulServices in every every app instead of IntentService, but I don't really want to change code in all the apps. Is there any elegant way to solve this?
Thanks #CommonsWare your thoughts were really helpful.
So to conclude, solution is that every app implements WakefulIntentServices and then core app starts WakefulIntentServices of all the apps.
I am developing a birthday reminder app which will notify user on specified date the birthday event. I have googled web and found alarm manager in android to carry out my task.
But i just want to make sure is this the only way followed in making apps like reminder or we have some methods also
I checked this tutorial
Yes, Alarm Manager is what you want. Don't forget to register a boot receiver to set your alarms back up after a reboot.
Also no this is not the only way. but other ways are more complicated still, and potential less reliable. For example you could save the date/time to a server, and have it send a push notification to set off the alarm at the appropriate time.
However Alarm Manger was intended for things like this, so best use it. There is always more than one way to do things, and any clever person can come up with a hackish way to do something. But Alarm Manager is easy, and standardized.
I did a search before asking so please don't tell me to do that.
I'm relatively new to Android so I get confused easily.
I'm making a simple app that changes the ringer volume according to time. For this purpose, I know I need a service that keeps running in the bg and monitor time. However, I really don't know how to approach this. I have the Professional Android Application Development book but haven't found anything that helps in there.
My question:
How to constantly check time without destroying the battery
If my code is needed (as proof of me actually working on this), I'll post.
You don't need a service. Use the AlarmManager class. Its like an alarm clock and it exactly what you need for this type of app.
need a service that keeps running in the bg and monitor time
No. Actually that's not how to do it. Services on android are different than your normal windows service/unix daemon. They should do their job and then stop themself until they get started again - to save battery.
You should start your service at a certain point in time by using the AlarmManager, it sends the launch intent to run the service. When the service is finished doing what it's supposed to do (change the rintone volume here), use Service.stopSelf() to kill it.