Pourquoi ne pas ce code de travail sur android 6 guimauve Api 23?

Pourquoi ne pas ce code de travail sur android 6 guimauve Api 23? Il ne jette pas une Exception, mais le code à l'intérieur callStateListener ne fonctionne pas.

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener callStateListener = new PhoneStateListener() {
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        //if(logAtive) Log.i(LOG_TAG,incomingNumber + " " + state);
        if(state==TelephonyManager.CALL_STATE_RINGING){
            Toast.makeText(getApplicationContext(),"Hey, receive your call. Phone is ringing.",
                    Toast.LENGTH_LONG).show();
        }
        if(state==TelephonyManager.CALL_STATE_OFFHOOK){
            Toast.makeText(getApplicationContext(),"You are in a call. ",
                    Toast.LENGTH_LONG).show();
        }
        if(state==TelephonyManager.CALL_STATE_IDLE){
            Toast.makeText(getApplicationContext(),"You are in idle state… ",
                    Toast.LENGTH_LONG).show();
        }
    }
};

telephonyManager.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);

Autorisations:

<uses-feature android:name="android.hardware.telephony" android:required="true" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_INCOMING_CALLS" />

Il fonctionne parfaitement sur Android 5.1.1 mais pas dans 6 API (Niveau 23)

peut-être en raison du nouveau modèle d'autorisation de
Ce code ne fait rien. Vous créez un PhoneStateListener et puis ne pas faire quelque chose avec elle.
Android n'est pas android.la permission.PROCESS_INCOMING_CALLS autorisation maintenant, il l'habitude d'être là plus tôt, vérifiez les autorisations

OriginalL'auteur mauriciosouza | 2015-09-28