Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handler not invoking

I am doing verification call from my app.Which should disconnect after 5-10 seconds which is configured.

Here is my code;

                    Intent callIntent = new Intent(Intent.ACTION_CALL);
                    callIntent.setData(Uri.parse("tel:" + phoneNumber));
                    callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                   /*It is never called up untill call got disconnected/hanged up. */
                            Log.d(TAG, "Disconnecting :");
                            disconnectCall();
                        }
                    }, 5000);

                    startActivity(callIntent);

The problem is disconnectCall() method not called until callIntent activity is suspended i.e user forcefully disconnected call/hanged up. I need to parrelly invoke disconnectCall() during call activity.Not getting where is the problem in code.

like image 929
Madhukar Hebbar Avatar asked May 05 '26 06:05

Madhukar Hebbar


1 Answers

You are calling startActivity(callIntent). This means you are transferring control to the caller app android. The call can now disconnected by android caller application when user wants.

like image 122
Danial Hussain Avatar answered May 09 '26 03:05

Danial Hussain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!