¿Cómo usar el método setWakeMode en el reproductor multimedia de Android?

I am using media player for phone ringing,i want to screen on when phone is ringing please help me

Gracias por adelantado

preguntado el 28 de agosto de 12 a las 15:08

1 Respuestas

To get the ringing event :

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

                                                            switch (state) {
                                                                case TelephonyManager.CALL_STATE_RINGING:
                                                                    break;
                                                                case TelephonyManager.CALL_STATE_OFFHOOK:
                                                                    break;
                                                                case TelephonyManager.CALL_STATE_IDLE:
                                                                    break;
                                                            }
                                                        }
                                                    };

Set the observer :

    try {
            TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
            telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
        }
        catch (SecurityException e) {
            // don't have READ_PHONE_STATE
        }

And to keep your screen on

solución 1:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

solución 2:

<uses-permission android:name="android.permission.WAKE_LOCK"/>

yourwakelock = getContext().getSystemService(Context.POWER_SERVICE).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName());

that's all for now

Respondido 18 Jul 13, 10:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.