"How do you hang up incoming calls (in Android of course)?"
First, I know this question has been asked and answered several times, and the response is always "you can't". But if we look in the market we get a few applications (all private software, no access to the source code... :-( ) that do this action, such as CallFilter, Panda firewall and others...
So... does somebody know how these apps do the hang up action, (or terminate, or disconnect or whatever you call it..)?
And other question, if the first don't get a response.. does somebody know how send an incoming call to the voice mail?
Of course, all questions are about how to do it programmatically. So with the voicemail question I know there's a flag in contacts that is used for that, but like I said, I'd like to know the programmatical way.
Thanks all!
Edit 1:
I have been seeing the LogCat traces using the application CallFilter and one trace seems to be interest, when it receives an incoming call, the PHONE_STATE is CALL_STATE_RINGING and fast appears one trace:
"05-03 19:32:34.416: INFO/UsageStats(78): Something wrong here, didn't expect com.android.phone to be paused"
and when CallFilter have done whatever do new trace "05-03 19:32:34.486:
INFO/UsageStats(78): Unexpected resume of com.android.phone while already resumed in com.android.phone"
appear, so i think CallFilter do something in one object com.android.phone, but i don't know how access to this.. any idea??
Edit 2:
I have performed at other times, and i don't see anymore the log traces above, so can be that the above may be that this does not mean anything.. i'm not sure..
the CallFilter application simply show one sec the incoming call, and then hang up.. how they do!!!???
I don't know how to hang up incoming calls, not sure if it's possible.
You can, i think, enter airplane mode programmatically, but it's a brutal method and really not advised. Changing such a setting should be done only by the user when he chooses to.
You may try using this API:
http://www.androidjavadoc.com/0.9_beta/com/android/internal/telephony/ITelephony.html
Related
The Android call logs give a type to each call, one of seven options: BLOCKED_TYPE, INCOMING_TYPE, MISSED_TYPE, OUTGOING_TYPE, REJECTED_TYPE, VOICEMAIL_TYPE, and ANSWERED_EXTERNALLY_TYPE.
My application is scanning through call logs, but I'm having difficulty interpreting this type information. The trouble is the options don't seem to be disjoint, i.e. a call I make that is rejected on the other end is both OUTGOING_TYPE and REJECTED_TYPE. A call that is incoming that I reject is INCOMING_TYPE and REJECTED_TYPE.
So it seems I'm missing something, and the docs themselves don't seem sufficient to make a proper interpretation.
My best guess is that BLOCKED_TYPE, MISSED_TYPE, REJECTED_TYPE, VOICEMAIL_TYPE, and ANSWERED_EXTERNALLY_TYPE all imply INCOMING_TYPE, and everything else is simply an unadorned OUTGOING_TYPE call. This is based on the assumption that the phone system does not provide meta-information on how the recipient of my call handled it, thus all the extra information about handling is coming from my phone itself and is about my actions, not theirs.
But I don't really know that. This is a very new area for me. Can someone please enlighten me as to what these call types really mean?
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.
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 can send MMIs using the approach described in e.g. Call forwarding. After the MMI is sent, there is usually a reply such as "Call forward successfully activated" or some-such.
Is it possible for the activity which started the intent to access this reply (especially for MMIs which query status messages such as "Is call forward on?") ?
Is it possible for my activity to prevent the system displaying the reply to the user directly? I mean this in the sense of "Not bother the user unnecessarily" rather than "stealthily doing things behind the user's back"; i.e. I don't care if the UI displays status icons etc, I just don't want the user having to confirm a large message box each time.
If not normally, how about on a root-ed phone?
In case this is MMI dependent, I'm mainly interested in MMIs that set, query, or cancel call-forward.
You couldn't necessarily block the popup, but for example in my app, you can send an sms to enable call forwarding, so you could run the mmi code (call startActivity from a broadcast receiver), and set an alarm to start the home screen about 10 seconds later. That wouldn't remove the popup, but it wouldn't be quite as annoying that way, I don't think.
If it really is important and you still care, you could break down the settings application using dex2jar and then use A java decompiler to read the jar file.
If anybody finds out the answer to this question, I would also be interested. I may do the work myself sometime, but I just don't care enough right now or have the time.
I would like to know how to intercept incoming calls and also how to forward them. I know there are several questions regarding this topic here and elsewhere on the net, but all the answers use the android.intent.action.PHONE_STATE action which is broadcast always after the phone begins to ring and the call screen is shown.
That's why I'm looking for a solution where i could intercept the call in an early stage before any notification (ringing etc..) has been done. I would like to know if maybe this is possible on a platform level in native code and if yes how ? Or perhaps with some kind of trick with the SDK ?
In general, if you can't do it in Java, you can't do it in the NDK. Most of the time the opposite is true: You can't do MOST things on Android in the NDK.
I don't know of a way to do that, and frankly doubt it exists: It would be a huge security hole if you could download an application that would forward calls to another number.
You may want to look at this source code, it may help you : http://code.google.com/p/auto-answer/
None of the existing apps in Android can forward a call based on a given number. All they can do is forward all or nothing. There's one app in particular (cBlocker) that can forward calls on schedule besides blocking incoming and outgoing calls and SMS based on rules.