I want to trigger specific code snippet at everyday 10.00AM while app will minimized pls help me?
You need to use Alarm Manager Class.
You can find suitable example HERE.
The easiest way to achieve this is setting up an AlarmManager that will fire your intent at the time you set it to.Inside your intent you can do whatever code you want.Else setting up a background service could be a good alternative,even tough takes a little more coding
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.
I want to trigger a notification in the status bar every x days(that the user will define in the application). How can i code this ?
Thank you.
AlarmManager was designed for stuff like that.
Assuming you already know how to code an android app, you can see these pages for code examples:
To trigger a notification in the status bar: http://developer.android.com/guide/topics/ui/notifiers/notifications.html
To run the trigger evey x days, you can use AlarmManager: http://developer.android.com/reference/android/app/AlarmManager.html
I am trying to detect Screen backlight On / Off.
I've found android.intent.action.SCREEN_OFF related its event.
But I don't know how to use this.
Can you suggest me about how to detect screen backlight on / off ?
I missing some example or sample code.
Thanks in advance.
If you still need to use a BroadCastReceiver, you have to register it in code using the registerReceiver(receiver, filter) on one of your Activities.
The intents do not fire if you register them in the Manifest.
Create a BroadCastReciever, Add an Intent Filter including your Intent (android.intent.action.SCREEN_OFF).
Just Override the OnRecieve function in the BroadcastReciver with your code.
Be Sure to include the BroadcastReciever in the Manifest File!
good luck! :)
I think you can have a look at this class. The method isScreenOn() might be what you need.