public void onReceive(Context context, Intent intent) {
if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
showText(context, "Call started da");
} else if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_IDLE)) {
showText(context, "Call ended da");
} else if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) {
showText(context, "Call ringing da");
}
}
void showText(Context context, String msg) {
Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
}
This is my code. What should I add in the last else if so that my app will automatically attend the calls?
I viewed other StackOverflow pages regarding this but couldn't get a clear view. Kindly help me out with this.
I also saw that we can simulate a headphone button being pressed which inturn attends the call? How far is that true? Can that be used?
Thank You
Auto answering is impossible. Android framework doesn't allow it. It is only avaible, when you can build your own android frame with modifying IntentManger. such as ASOP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.