How to change from a Service to an Activity in Android?
<p>I have written coding on playing an alarm remotely, but now i would like to make sure the volume keys are disabled, no matter the volume down key is pressed the volume still remain loudest. but as i know in an Android service, interception of volume keys is impossible, so I would like to change my current coding from Service to Activity, so i am able to do so.. But I have no idea what alteration should make in order to achieve this... Need someone help in this... thanks</p>

<p>RingAlarmService.java</p>

<pre><code>public class RingAlarmService extends Service{

MediaPlayer player;

@Override
public IBinder onBind(Intent intent){
    //TODO Auto-generated method stub
    return null;
}

@Override
public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
}

@Override
public void onStart(Intent intent, int startId){

    super.onStart(intent, startId);
    player = MediaPlayer.create(RingAlarmService.this, R.raw.alarm);
    player.setOnCompletionListener(new OnCompletionListener(){

        public void onCompletion(MediaPlayer mp){
            stopSelf(); 
        }
    });
    player.start();  
}

@Override
public void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    player.release();
}
}
</code></pre>

<p>RingtoneService.java</p>

<pre><code>public class RingtoneService extends Service{

boolean tone = true;

@Override
public IBinder onBind(Intent intent){
    // TODO Auto-generated method stub
    return null;
}

@Override
public void onCreate(){
    // TODO Auto-generated method stub
    super.onCreate();
}

@Override
public void onStart(Intent intent, int startId){
    // TODO Auto-generated method stub
    super.onStart(intent, startId);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId){
    // TODO Auto-generated method stub
    AudioManager manager = (AudioManager)getSystemService(AUDIO_SERVICE);
    manager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    int maxVolume = manager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    manager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, 0);

    MediaPlayer player = MediaPlayer.create(RingtoneService.this, Settings.System.DEFAULT_ALARM_ALERT_URI);
    tone = false;

    if (tone == false){
        player.start();
        tone = false;
    }

    while (player.isPlaying()){ 
        player.setLooping(true); 
    }
    player.release();

    stopSelf(); 
    return START_STICKY;
}

@Override
public void onDestroy(){
    // TODO Auto-generated method stub
    super.onDestroy();
}

}
</code></pre>
