package com.eni.android.keyevent;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;

public class KeyEventEjemplo extends Activity {
	
	private static final String KEY_EVENT_ACTIVITY = "KeyEventActivity";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.key_event_ejemplo, menu);
		return true;
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		super.onKeyDown(keyCode, event);
		if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
			Log.v(KEY_EVENT_ACTIVITY, getString(R.string.volume_down));
			return true;
		}
		if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
			Log.v(KEY_EVENT_ACTIVITY, getString(R.string.volume_up));
			return true;
		}
		return false;
	}
}
