Is it possible to detect incoming call before default phone application, and prevent to active default phone application in Android?
Looks like it may not exactly be possible according to this -> Create a custom call handling Application.
Anyway more research may be required on your side to check if it can be. Multiple posts on Phone broadcast receiver can be used as reference.
Related
This question already has answers here:
Android dialer application
(4 answers)
Closed 5 years ago.
Why I think it's not a duplicate:
I need to replace in-call screen, for both incoming and outgoing calls.
My requirements:
I need to create an Android app that will intercept both incoming and outgoing calls;
I need to display my own UI for the in-call screen.
Use case:
Idea is to create a very simplified android experience for elderly users;
They will be given a tablet with application in a full kiosk mode that will then allow them to receive and call only predefined whitelist of
numbers;
They will get video calls, and etc;
My constraints:
It needs to be stable solution;
I don't need to handle many types of phone, most probably one make will be choosen and ordered in bulk;
It needs to work on recent android;
So is intercepting incoming and outgoing calls possible in android? I want to create my own in-call screen that will used instead of system one.
What I can do to the phone:
I don't (right now) control make of the phone
I can get device admin permissions
I don't want to root the phone or install custom ROM (right now)
Right now only solution I can think of is:
Obtain root access to the phone;
Replace dialer app with our own application;
This might be not possible as I'd need to integrate my dialer/in-call app with this specific system, and they could be intimately tied.
Questions
Is overriding in-call UI feasible in recent android systems?
If so, how it is possible;
The only application that is really able to trigger outgoing calls is the ROM Dialer application that comes with your Android OS. There are a couple of other apps out there, but they only trigger an intent which invokes the native dialer.
What does this mean for you?
Outgoing calls: You can write an application that checks if a number is in the whitelist for example, and which provides a simple, well-defined UI for elderly people. However, this application will then forward the call to the native dialer app. This is not a problem for what you want to achieve in general.
Incoming calls: You simply cannot replace the incoming call screen with your custom implementation. And there is no way of catching a call and forwarding it to your own app instead of the ROM dialer. This is for security reasons.
I tried to do something similar for a research project, where I wanted to provide a custom dialer application for patients suffering from Parkinson's disease. Unfortunately you were right with your guess that what you would like to achieve is only possible if you have root access to the phone.
I want to know if its possible to create an app that activates in the background when the user gets a phone call ? and if it is possible I'd like to know where I can find more information about how the app can interact with the phone call.
For example, is it possible to turn off / on the mic during a call or intercept it, add sounds in the background etc.
You could use "Broadcast Receiver" available in the API Android.
Here tutorials about those (specific to your very question):
http://androidexample.com/Incomming_Phone_Call_Broadcast_Receiver__-_Android_Example/index.php?view=article_discription&aid=61&aaid=86
And another :
http://www.vogella.com/tutorials/AndroidBroadcastReceiver/article.html#tutorial_receiver
I'm trying to get an idea of what's possible and what isn't in terms of using a custom dialler app for internet calls.
The idea is that the standard Android dialler be used when no internet connection is available, but use a custom-written VOIP dialler / caller app whenever an internet connection is available.
I see that in the Android call settings you can set it to use Internet calling whenever a connection is available. How does this work? Does this simply tell the native dialler app to use internet calling, or is there actually a specific Intent or something that gets fired when an internet call is made so that I can open my custom SIP app?
And also, is the 'standard phone app' icon always linked to the standard phone app, or can you override this phone icon to open your custom VOIP app when a connection is present?
So basically, is there a way to seamlessly and automatically switch between the standard dialler and the custom SIP dialler based on whether or not the phone is connected to the internet?
If not, is this something that could be done by customizing Android?
Thanks,
There are four possible ways of doing what you want that I know of:
1. Replace the Android Dialer
This is hard and a lot of work. The Android Dialer (last time I checked anyway) WAS the telephony stack in Android. So to replace it you have to replace the complete telephony stack (including any public API) i.e. handle all cellular (and now sip) calls in and out of the device. Also the only way to replace it is to root the device as it can't be replaced normally.
2. Provide your own Dialer that is separate to the main dialer.
This has it's advantages that you will never get into "trouble" with anything else.
3. Hook into the outbound call API (ACTION_NEW_OUTGOING_CALL)
This is something that is pretty cool and I haven't seen any other OS allow you to do. Basically you can trap when either the normal dialer starts to dial a number (or when another application starts to dial a number as well) and you can either allow it through, modify it or cancel it. Behavior I've seen from sip clients is that they will cancel the call and put up a selection screen prompting where you want to send the call (sip, cellular or something else).
Here is an example of it's use.
The downsides are:
You can be fighting with other applications to which gets first go. There is a 'priority' setup, but all I've seen is everybody wants to be number one.
On some Android devices where the OEM providers that own Dialer, they don't always fire it!!!
4. Detect when the dialer is shown and show your own dialer in front of it.
This works and does allow you to provide a nicer more integrated feel as you can provide call type selection within the dialer, as well as other custom number lookups but that can be a little tricky to do on some devices.
I would suggest 3 to begin with as it's pretty easy to do and you can get something up going pretty fast. In code that I have worked on, we have done 2, 3 and 4 and also looked into 1.
Can anyone help me how to create a fake call.
as same mobile I want to create a fake name or number and fix timing : Example
5sec.(here i am using the toggle button enable disable fake call)
You cannot create fake calls. You could pretend that it is a call by re-creating the look of dialing screen in your application and show it when you need to fake the call, but you cannot fool (perhaps it might be doable on rooted devices, but I assume you target regular devices) the system and make system dialer (or replacement) to think there's a call while there's not.
Is there a way to use default incoming call screen with its functionality (answer and reject) from inside my application.
I want to make fake call from inside my application and i don't want to create custom incoming screen but use default incoming call screen on device because different devices have different incoming screens.
No, this can't be done using the standard SDK. First, the call screen activity can only be launched by the system. Second, vendor-specific skins of Android often replace the default phone app with a custom one, so it's unlikely you'd be able to do this on all devices with just a single piece of code even if it were possible.
Your best bet would be to try to recreate the incoming call screen for the most popular devices and detect which device the user is running, which I know isn't what you wanted to hear. Sorry.