Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will this method be called? (Still needs an accepted answer...See details in answer)

TL;DR:

Does onPause method get called during phone call?

I have a permission to READ_PHONE_STATE which I don't want. So, does the onPause method get called on a phone call, so that I can mute my apps audio there?

private PhoneStateListener phoneStateListener = new PhoneStateListener() {
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {

        if (doesUserHavePermission()) {


            if (state == TelephonyManager.CALL_STATE_RINGING) {
                onPhoneCallInterrupt(); //Method I made that mutes audio for phone call
            } else if (state == TelephonyManager.CALL_STATE_IDLE) {
            } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                onPhoneCallInterrupt(); //Method I made that mutes audio for phone call
            }
        }
    }

};

This requires this permission:

enter image description here

Which I want to get rid of. So do I have to explicitly listen for a call? Or can I just mute in the onPause() ?

Here is my app, you can see the permission requests on an attempt to download:

https://play.google.com/store/apps/details?id=com.culybrace.ruchir.buttonsmasher&hl=en

like image 796
Ruchir Baronia Avatar asked Dec 14 '15 03:12

Ruchir Baronia


People also ask

Why do we need to use effective questioning in our discussion?

Questions can review, restate, emphasize, and/or summarize what is important. Questions stimulate discussion and creative and critical thinking, as well as determine how students are thinking. Questions help students retain material by putting into words otherwise unarticulated thoughts.

Why is Google verifying my card?

After you add a payment method, you may be asked to verify it. This step helps Google Wallet and your bank to protect your account. Based on your bank, you can choose from the following options. Your verification code comes from your bank, not Google Wallet.


1 Answers

In my experience, It depends on phones. there are 2 cases. 1. when ring comes -> new Call Activity starts. : In this case onPause is called because new Activity is over your app. 2. when ring comes -> ring window shows over the app.(not activity) : In this case no Activity call back is called. and user can use the app as before the ring called.

you may can use AudioManager without permission, check this out AUDIOFOCUS_LOSS called after a phone call in android

like image 63
Bansook Nam Avatar answered Oct 05 '22 23:10

Bansook Nam