You can't just remove existing layout from an existing app or run calling in background (like hiding from the user). However, you can create a new dialer app and NOT OPEN THE DIALER SCREEN. Instead, you can open a new activity.
First of all, include this permission in your AndroidManifest.xml
<uses-permission android:name="android.permission.CALL_PHONE" />
Then, add this function and use it when you want to.
/**
* Opens a new ACTION_CALL Intent instead of ACTION_DIAL.
* @param num String representation of the number you are calling
*/
private void call(String num) {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + num));
startActivity(callIntent);
} catch (ActivityNotFoundException e) {
Log.e("sample call in android", "Call failed", e);
}
}
Note that it's not calling startService(callIntent)
. It is starting a new Activity instead.
Hope this helps.