I want to design an app that will make the LED blink whenever a message or a phone call is received. I've read about broadcast receivers but I'm not sure how to work with them or where to start.
If anyone can put me in the direction where I can perform an action whenever phone rings? Maybe a small example or tutorial link would be nice.
Regards
Saeed
This should help with the broadcast receiver stuff: http://www.vogella.com/articles/AndroidBroadcastReceiver/article.html
This should help with LED stuff (half way down):
http://mobile.tutsplus.com/tutorials/android/android-vibrator/
Related
I want my app to listen for intends broadcasted by the call application, and when a call intend is broadcasted for a specific number I want to launch a dialog. I read that "A broadcast receiver may not display dialogs, and it is strongly discouraged to start an activity from within a broadcast receiver" https://developer.xamarin.com/guides/android/application_fundamentals/broadcast-receivers/ so I am assuming I should instead make the broadcast receiver launch a service that then launches a dialog. Can anyone confirm this? Also any simplified examples would be highly appreciated
Thanks!
In the example below, the app uses a BroadcastReceiver to detect a phone call number and decide whether it should answer or not:
How to reject incoming call programatically in android?
So using a BroadcastReceiver for that isn't that bad.
If you just want to show information about the phone call, you can display an Notification, as suggested by Jon Douglas in the comments. Displaying Dialogs from BroadcastReceivers isn't allowed (also disencouraged).
Hello all i will explain my question a little more. I'm not native english speaker. So maybe my question is on the internet but when i search i only found something i already know.
I have a Xperia U with the illumination barre. I use it as a notification for sms. I already know how to receiver SMS and the event of unlock screen
What i will now is 2 thing.
1- Possibility to know if the last sms was read by the user or not(My apllication is just a notification center and not a sms handler so the sms reading is doing by official app or user app like gosms)
2- Possibility to know if phone is already unlock, i will remove notification if it is.
I'm not very clear but i find this difficult to explain if you don't undestand the question say it i will reformulate it.
Possibility to know if the last sms was read by the user or not(My apllication is just a notification center and not a sms handler so the sms reading is doing by official app or user app like gosms)
There is no concept of Read in SMS. You can get a delivery notification for when it reaches the user's device, but you can't tell if the user read it or not.
Possibility to know if phone is already unlock, i will remove notification if it is.
You will need to dynamically register a BroadcastReceiver for ACTION_SCREEN_ON and ACTION_USER_PRESENT broadcasts.
I'm looking to write an android app that invokes a screen/activity after some one has entered the default android unlock pattern correctly.
I'm assuming that the best way to do this is run a service in the background that waits for this activity then on detecting this invokes an activity screen displaying the information?
Does that sound like a sensible way of doing things or is there a better way?
Also if anyone can point me at examples of this that would be amazing.
Cheers
Ric
Basically you need to register a BroadcastReceiver for the action ACTION_USER_PRESENT
ACTION_USER_PRESENT is fired after ACTION_SCREEN_ON, usually when the keyguard is gone.
So create a handler and wait for ACTION_USER_PRESENT. When you got it, implement what you want for your activity.
Create a broadcast receiver to recieve boot_complete action then create a service and start it from onRecieve of broadcastReceiver .
A good tutorial here
I am an android developer I have a problem..
I want to be get notified when the phone screen goes to sleep
PLease Help wiith a sample code.
Set up a BroadcastReceiver to watch for ACTION_SCREEN_OFF broadcast Intents.
I have a program that has a broadcast receiver that listens for Phone_State and then sends a user defined intent.
Well, my problem is that the system also sends out an intent (the one that I am trying to replace with my program) .
So I am trying to find a way to CANCEL the systems intent.
I have found that if i have a timer just wait for a little bit, then I can send mine after the systems, but that is not very good, and sometimes defeats the purpose of my program.
Also, i cannot set my program as a default because it is not a full dialer program. Just one action of it.
Someone please help me find how to listen for and cancel a system intent/activity....
Someone please help me find how to
listen for and cancel a system
intent/activity
You cannot "cancel" an activity, period.
You cannot replace the dialer.
If the system Intent was sent via sendOrderedBroadcast(), then you can call abortBroadcast() from your BroadcastReceiver, and any lower-priority receivers will not get the broadcast. However, I have no evidence that ACTION_PHONE_STATE_CHANGED is an ordered broadcast, and I sincerely hope it isn't.
Whatever you are trying to do probably should be accomplished via modifications to your own custom firmware.