As per android developer documentation
Android 8.0 (API level 26) introduces several new permissions related to telephony: The ANSWER_PHONE_CALLS permission allows your app to answer incoming phone calls programmatically. To handle an incoming phone call in your app, you can use the acceptRingingCall() method.
How my app give voice answer to incoming call ?
but I have not found any guide or examples about of this . so
I want automatic answer with voice(from raw folder in app) (I have need guide or example code like answering machine)


For answering a phone call, this is available only from Android O. Before, it might not work. Here's a code for it:
For hanging up a call, this was added officially on Android P, but the workaround seems to work on most cases I've tried so far (doesn't work on Nexus 5x with Android 8.1, for example) . Here's code for this :
So, for both answering and rejecting calls, the safest way to do it, is to have it run on Android P... :(