I am new in android.
I want to trigger incomming and outgoing calls, and code should be executed when any call( incomming and outgoing) started and ended...
I know that BroadcastReceiver is helpful for that. But can u give me the code/idea for that..
Thanks in advance...
This question is answered many times in forum please check Is there a way on Android to intercept incoming calls/SMSes to either block/unblock it?
This might answer your question.
Related
I am looking for a way to react to the amount of missed calls changing.
I've figured out how to get the current number of missed calls, but what I would like to do is send it to a server, so I would need some kind of broadcast listener or service I assume.
I really have no idea here, can you guys help me out?
I need to start an action after a call has ended. No button clicks or anything like that, I need it for both incoming and outgoing calls. I understand I have to deal with PHONE_STATE_IDLE.
Does this mean I have to have listeners to listen to incoming and outgoing calls, and when they start and finally when the pgone goes IDLE after that?
Or is there a simpler way. I checked the Telephony docs from Android, but the 3 PHONE_STATE cases mentioned there are a bit vague for me.
Also , most answers related to this are both old and lead to a dead-end (for me, atleast). Anything concerning Marshmallow, or better yet Oreo, would be of great help.
I've been exploring Android's Telephony Manager a bit and fount out there is a way to listen to such events as ringing, off hook and idle. However, it's not enough for me...
When the call is actually initiated, I get an 'offhook' event, but I get nothing when the person I'm calling to, presses the 'Answer' button.
Is there a way to know EXACTLY when somebody actually pressed the Answer button when I call to him/her, in other words I want to know when somebody answers the call?
Any help\suggestions will be appreciated...
I don't think its possible. There's no such state/event at least I know of. So your best bet would be to stick with CALL_STATE_OFFHOOK.
In my application I initiated an outgoing call and I am using PhoneStateListener to know about call state.
Whenever I start making call the phone state is TelephonyManager.CALL_STATE_OFFHOOK. When call recipient answered the call, I am not getting any change in phone's state.
I tried many but failed to get this answered state. Somebody told use bluetooth's HFP (Hands Free Profile) to get call answered state. But I didn't get any information about HFP from android developers website.
If anybody faced same problem and got the solution, please give your valuable suggestions.
The CALL_STATE_OFFHOOK doesn't change when the call is answered by the recepient:
Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
The state shouldn't change as long as the phone is in call, whether it's answered or not.
This question had been asked many items, and so far none of the those I found have been solved: Detect if an outgoing call has been answered, Android : How to get a state that the outgoing call has been answered?, Android : How to get a state that the outgoing call has been answered? (There are many others). The solutions provided there rely on the CALL_STATE_OFFHOOK state to change when the call is answered, which doesn't happen.
Seems like there is no public API which can be used to get the outgoing call state. The best workaround I see is what Vivek Khandelwal suggested., it's not so long to code nor has heavy performance overheads. Unless adding too many permissions (Now you need to add READ_CALL_LOGS) is a problem, use it.
I too had the same problem. This may not be the answer for your question. I am just sharing what I did.
I had an activity which opens the Contact and can make a call. What I wanted is, to known whether the call was successful (i.e recipient answered to the call).
There was no solution i found at that time with PhoneStateListener.
So as a work around, what I did is checked the Call Logs if it has a outgoing call to the phone numbers of that contact after starting the Contact Activity.
See if his help.
you want something specific to bluetooth? Otherwise I can provide sources
I want to write an application in which every call information should be logged. Till now I can log all incoming calls by making use of PhoneStateListener but dont know how to listen outgoing calls. If anyone had worked on such issue please let me know the way how to do the same.
Thanks in advance.
Try to look at following thread
How to get Call number as well as the duration of the call made by a user in Android?
from the following thread you can fetch whether the call is incomng or outgoing or missed
// type can be: Incoming, Outgoing or Missed
int typeColumn = c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
Thanks