Handle Back button event

In Android, one of the troublesome is to handle back button, I thought.
Back button performs to finish Activity, back previous Activity etc…

Sometimes, developers don’t want user to press back button, because other operations are still going on.
Please wait!!!! Anyway.
How to handle it?

Handle back button event

Use onKeyDown of Activity. It’s an answer.

public boolean onKeyDown ( int keyCode, KeyEvent event )
	if (keyCode != KeyEvent.KEYCODE_BACK)
		return super.onKeyDown(keyCode, event);  // This is original event operations
		return false;

keyCode is key code. Each button has key code.
To prevent original operation, should separate.