Hello I was wondering if there is a way to override the incoming call screen to add more functionality to it? If so could you either point me in the right direction or provide some sample code?
--------------------------------------------------EDIT: --------------------------
I got the receiver working well when the call comes in but how would I get the current window to override the call screen? This is what I got so far... but i get a classCastException trying to cast to activity from context, I cant think of any other way to gain access to the window.
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
String state = extras.getString(TelephonyManager.EXTRA_STATE);
Log.w("DEBUG", state);
Log.w("DEBUG", "-------------------------------------------------- Broadcast Received");
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
String phoneNumber = extras
.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Log.w("DEBUG", phoneNumber);
Activity activity = (Activity)context.getApplicationContext();
Window window = activity.getParent().getWindow();
window.addContentView(window.findViewById(R.layout.textalertbuttonview),null);
Log.w("DEBUG", "------------------------Button Added");
}
}
else {
Log.w("DEBUG", "---------------------------------------------------no Extras");
}
}
--------------------------------------------------EDIT 2: --------------------------
It doesn't seem after some research that I can actually add elements to the actual incoming call screen. So I will have to make my own view and override the incoming call screen. But I am still open for ideas... I saw incoming call plus but can not find the source code for that project.
You can either tap on set for all to make it the universal caller screen for any incoming call or tap on the contact + sign at the bottom to select a contact. The second option is for anyone who loves to put a custom photo on the caller screen. To do that, tap on the just add your photo option from the home screen.
Go Settings > Sound > Do Not Disturb, and check what Notifications is set to. Check that Phone app notifications haven't been disabled. Touch & hold , then touch > Notifications and make sure they are on.
Enable call notification Look for the 'apps' option in your phone settings and open it. Then open 'manage system' apps and look for 'call settings'. Open 'call settings' and select 'advanced settings. Open 'advanced settings' and check if show call notification is enabled.
Generally speaking: You can set a BroadcastReceiver listening to PHONE_STATE:
<receiver android:name=".CallsBroadcastReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
Then inside this receiver (after checking the state of the phone you want to handle (ringing, in call, hanged up, etc.) you should get the current window (which should be the call screen) and add a view to it. And of course remove the view once the state is not the one you want to handle.
Very general, but that's the idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With