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.
Related
I am trying to build an NFC enabled application that transmits data to another device via Android Beam (pushing a NDEFMessage).
While I know there is a success callback void onNdefPushComplete(NfcEvent event), I can't find a failure callback, which would be really useful.
I tried to think of other way to sort of guess whether the transfer happened, if it succeeded or failed but cannot really find anything satisfying. Even a dirty timer would not work since I cannot know for sure when and even if the user actually starts the beam.
I feel pretty much bound by the API since the OS is handling most of the functionality and the application is only providing the message to send.
Any suggestions, something I might have missed? I'd rather avoid rooting the device if possible, but if it cannot be accomplished without tinkering with the core NFC code, then so be it.
Cheers
No, there is no such callback. Or a notification or anything that would give you a clue that things didn't worked.
Unfortunately.
In general the Android Beam API has not been designed with error handling in mind.
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.
How are things now
This has been discussed in many questions but neither one offers a good solution. Things look simple, after having a BroadcastReceiver is really easy to intercept and block a call. The main issue that appears is the default Android incoming call screen. You know, the one with sliders for answer/end call. Because i have some rules to block the call, there is a small delay before the call gets hangup. In all this time, the Incoming call screen is active.
How I want things to be
I want the user to not get notified by this call blocking, as in my application I have a clear Log of all blocks done. So, the main thing remains: how do I prevent the Incoming call screen from starting?
It is not possible to completely block the calls but you can achieve this by listening the call and then disconnecting it. It's behaviour may be different in different devices. It may show negligible flicker over some device but that's the only solution.
Here is the approach how you can do that:
Android: Taking complete control of phone(kiosk mode), is it possible? How?
You can use BroadcastReceiver but for alomost blocking experience you need to use Service.
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.
"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