As part of my application I need to block incoming calls. I.e While my application is running, I will drop any call and simply notify the caller that the user is busy or something similar.
I wish to do this using the android SDK, I hope to support Android versions 2.2 and above.
I've already looked at
How to block calls in android
(Says, and I quote "It is Mission Impossible for the time being.")
Intercept incoming calls
(Also says not possible)
Can we intercept incoming call in android?
(Gives telephonyService.endCall(); as the solution)
Create a custom call handling Application
(Says it's not possible)
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/gc5vOHjBE30
(discussion seemed inconclusive)
But they don't seem to be of much help.
Even after reading of a lot of questions on stack overflow, google groups and other forums I am still not clear as to whether this is possible or not. Also a lot of the questions and threads are over 2-3 years old, thus adding to my confusion.
And if this is possible then what would be the best way to do it?
Seems like this is not possible after android 2.2 which dropped the hidden itelephony interface.
So yes "It is Mission Impossible for the time being."
Related
Is there any way the android system can inform a service that an activity or a task in the system(not only my activities/tasks!) has somehow changed (e.g. another activity is brought to the front or is stopped)? This is to avoid polling the same information, of course.
There is an identical question here, but it was asked 3 years ago, so in the meantime, maybe someone has an answer to this? As a supplement to this question: If the answer is no, is there any way someone could enhance this feature by, let's say, low-level programming or something?
No, there is no general solution. You can only record this information in the lifecycle methods of your own activities. And starting in Android 5, even polling does not work. ActivityManager#getRecentTasks() was nerfed. From the docs:
This method was deprecated in API level 21. As of LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak personal information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks (though see getAppTasks() for the correct supported way to retrieve that information), and possibly some other tasks such as home that are known to not be sensitive.
Since this is considered a security issue, you can bet that if there is a low-level way to do it, Google will eventually find out and break it.
Isn't what you want covered already by the activity lifecycle events?
Aren't onPause() and onResume() sufficient?
i am feeling lazy sorry, try this logic.
check this post. what you would want to achieve here is record all the Tasks running currently; and in a loop you keep checking, you will be notified when a task die by checking the overall running Task, loop through and you will know who died- but this is limited not all versions, and some people will tell you, it is not meant for that.
Scanned through the Android API (reference) documentation, but didn't find specific API that allows one to achieve the following:
Be notified of an incoming call
Automatically answer or reject the incoming call
While a call is in progress, be able to capture the audio
Play a pre-recorded message, after answering the call
The intention behind the questions, as most might have guessed, is to have an automated answering machine type of application. I have seen such applications on Nokia Symbian OS devices.
If such functionality requires rooting the device, I'd still be interested in knowing the API's available once rooted!
As an aside, is there are separate API reference documentation for API's available to rooted devices ?
For the latter parts of your question, No.
Imagine for a second there was, and you had an app installed that uses it. It could record your conversations and send them to a 3rd party. The app might not even disclose that it does this.
That sounds like it would be a huge security problem... Don't you agree?
It would appear I am mistaken about the call recording part - several apps available on google play (such as this, this, and this) does call recording, at least of the user making the call.
For #1, this is covered by marcin_j's answer
For #2, these SO answers show you can accept or reject a call programmatically.
For #3, I did a bit more detailed search on this, which reveals a related Stackoverflow question and answer, which provides info on recording audio (as per the above linked apps). Please keep in mind there are likely legal requirements around recording calls.
For #4 (playing a message to the caller), the only info I was able to find on this says it is not supported. It's hard to find much more info on this with so much clutter on search coming up with apps that are basically an audio version of caller id.
Most of these answers are on StackOverflow already; hopefully bringing it all together here helps you.
You can use android.intent.action.PHONE_STATE broadcast, and check TelephonyManager.CALL_STATE_RINGING state. Requires android.permission.READ_PHONE_STATE.
2/3. Dont think you can do this, at least not on non-rooted phones. Maybe someone else will give better answer.
We are working on an application similar to "Funny Call" on Google Play.
When user makes a call to another another contact, we would be intercepting the call and will add some effects to it and then this modified sound will reach the recipient.
I've searched for the solution to this problem and found out that many developers say Android does not support this.
Android API for call sound stream manipulation
Can the Android API be leveraged to modify the caller's voice during the call?
But, I would still like to know if its really not possible straight from the horse's mouth. I would like to know if there is any specific reason behind this.
Is there really no way to achieve this?
Can you please also tell me if there is any possibility of this being possible in near future?
Is there really no way to achieve this?
If you read through the comments on the app you cited, it would appear that they are doing VOIP, and that their servers are then actually placing the call, as that is why there are calling rates to different countries. I see no evidence that they are using the on-device telephony capability. You, of course, are welcome to supply such evidence, if you have any.
I have tried to code this with Android's included android.speech.SpeechRecognizer class with no success.
Basically, what I am trying to do is making my app constantly listen for one keyword that will fire an intent whenever the keyword is recognized. I know that this will use a lot of battery.
For example - you are talking with a person. Normal conversation. The phone is actively listening and recognizing every single said word and listening for the keyword.
Let's say the keyword is "cheese" in this instance.
Whenever you say "cheese," the application fires an intent that starts up another part of the app.
I have tried to use speech recognition as a service but things didn't really go as planned. Maybe I did a mistake, I don't know.
I've been trying to accomplish this for 2 days in a row now, for more than 24 hours work time combined. If I am being too broad or infringing any of SO's rules, I sincerely apologize and ask my question to be deleted.
My question is - how would this be possible? Of course the SpeechRecognition that is included with android itself would be preferable, but it definitely will be a hassle because it is not even designed to work for extended periods.
from my research, there is no way to do this using the standard google voice recognition server. They way it works is once sound/word is recognized, the recognizer returns a list of what it thinks it heard with an associated confidence score.
to do what you are asking, you would:
have to keep re-activating the recognition service every time it fired a recognition event, until it matches the word you want.
your app would have to 'keep-awake' the recognition service. you could do this by creating a service that periodically wakes up your handset and resuming the service/activity.
I would not recommend either of these options considering that the battery life is really reduces by the voice recognition service being constantly on.
Unfortunately, I do not think there are any native Android APIs that will fully suit your needs. I would recommend checking out pocketsphinx.
It is a pretty robust speaker-independent speech recognition API from CMU that is more intended for tasks such as this. You can also check out a tutorial for getting started here.
Google has not made API support for "OK GOOGLE" public and left it on vendors to change or pass the support to consumers.
I think best bet at this time would be build source code yourself and then call the API's. As an example below google library has low level details of implementing recognizer. I'm not sure why google does not made it public.
I don't see an easy way to implement and test it.
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.3_r2.1/android/speech/srec/Recognizer.java
According to this tutorial the only way to disconnect the vpn service is to use the 'system-managed dialog'. This can be done manually by dragging down the notification bar and selecting it from there, however this is not a good solution for my problem.
I need to be able to bring this dialog up from within my app when a 'disconnect' button is pressed, however I can't find any documentation on how to do this.
Can anyone help?
Right now the only public and recommended way to disconnect is unfortunately just through the notification. The functions for disconnecting or even bringing up the dialog are otherwise hidden unfortunately.
Of course, that doesn't necessarily mean that they can't be accessed, but that way lies much pain. I haven't tried this in this specific case, but I have done this in the past, way back, with the music player to find out what was playing (for audio scrobbling). So if you absolutely must find a way to do this, no matter how hacky, then you could try this, but keep in mind that 'ere be dragons - this involves accessing a private API that you are not supposed to. That API could change on a whim between any two given builds of android (not just platform versions either), because it is supposed to be private and internal. You would need to make your code very resilient to failure here, and frankly it'll never be anything more than hacky and a PITA.
Right, all that said, see line 171 in this
That's what you want to do. Except you can't see the things you need, right? So you need this AIDL for the service (and possibly a bit of reflection too, I forget - haven't done this in a long time).
This blog post describes something similar, though not in much detail. It's hard to find things talking about, since it is an incredibly discouraged practice.
I think it is fine just to close tun descript and let the Service end. This will effectlivy end the VPN (but the app in question will still hold the permission to open a VPN again). The notification (key symbol) will also go away. If you are trying the VPNService of another app that might be tougher. Perhaps you should ask the author of that app for an API.