0

I have a probleme while developping an application. I'm calling the "onReceive" method of my "BroadcastReceiver" from "onCreate" method of the service, and it works fine, but the problem is that i would like to change the volume MODE from MEDIA to RING. I've made a lot of researches but i didn't find a solution. This is my Boadcast class, (just trying to catch the media volume and switch it to ring volume control), ...

final class ScreenReceiver extends BroadcastReceiver {

@Override
public void onReceive(final Context context, final Intent intent) {
    Log.i("CIRUS ON RECEIVE", "je suis dans la methode onReceive");

    if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
        // stuff
    } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
        AudioManager mAudioManager;

        mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);


        mAudioManager.setStreamVolume(AudioManager.STREAM_RING, 7, 0);
        Log.i("Cirus OnReceive ScreenReceiver", "Code executé -> "+AudioManager.STREAM_RING);


    }
}
}

Of course, the manifest is well configured.

Thank you all in advance.

Cirus
  • 11
  • 1
  • 2
  • Shall i override the onkeydown method ? – Cirus Jun 14 '13 at 18:04
  • This is the most similar topic, and no solution ... http://stackoverflow.com/questions/8037390/calling-setvolumecontrolstream-from-a-service – Cirus Jun 14 '13 at 18:52

0 Answers0