The android alarm duration is basically at 1min (I think).
I would like to change it, so I can set the length/the duration at 4min for exemple (the duration of a song).
Can you tell me which methods I can call to change it ?
Can you guide me please ?
Thank you in advance !
I think you can use AlarmManager for this. http://developer.android.com/reference/android/app/AlarmManager.html
It has setRepeating method where you can set the interval you want (the second parameter is time in milliseconds that the alarm should first go off).
Related
I want to start an activity if the clock is 15.00. Is there any reference ?
Assuming i had running services in my background.
EDIT
I have value from database. Then the activity will trigger based on clock that i saved from database. So if the database has values like 01.00 , 13.00 , 22.30 then the activity will start when the phone clock match as that 3 value.
You can use an AlarmManager for that
This post will help you. Use AlarmManager to set a repeating alarm. The time can be set.
Android notification app not working properly
I'm new to android. I need to make a program that is very basic. It needs to display a random image from my drawing folder. I can do that part because frank n stein posted How To Display Random images on image view
But I need it to stay on the screen for 90 seconds (and count down) or until a user clicks a button. Can someone help? I would really appreciate it. If you post an answer please assume I know absolutely nothing...barely the basics. But I'm trying to learn. :)
You can use a for loop with Thread.sleep() or a CountDownTimer or AlarmManager or a Handler with postDelayed option.
You can use android alarm manager with broadcast receiver,you will set alarm +90 second to this time and receiver the alarm or you must to use timer.But timer is spending battery more than alarm manager.
You can follow this tutorial for alarm manager and i think you must follow :)
http://karanbalkar.com/2013/07/tutorial-41-using-alarmmanager-and-broadcastreceiver-in-android/
I have an array of specified hours for each day, when brightness should by changed for application which is awake 24/7. It happens twice a day.
What I want to achieve is to find the most economical way of implementation that problem.
Should I use AlarmManager or maybe there is a better sollution?
Activity is always awake...
If your app doesn't show any UI while it's awake, use the AlarmManager.
Finally, I decided to use an AlarmManager with BroadcastReceiver setting value in SharedPreferences and then in Activity I have a Handler which checks that value.
Right now I use thread.sleep(3000) and print the data in log for every 3 seconds but now I want to change it to 15 minutes.
WHats the best to use?
Is it alarm manager or handler ?
What's wrong with:
thread.sleep(1000*60*15)
I try to use datepicker to set the time, and I also built an alarm for that time I set, but the alarm always paly at current time instead of my set time, I don't know why, please help, thanks! here is my code:
You should remove this line:
alarmTime.setTimeInMillis(System.currentTimeMillis());
as it set the time of the calendar to current time.