码迷,mamicode.com
首页 > 其他好文 > 详细

屏蔽掉返回键,menu键,Home键

时间:2014-06-24 21:12:09      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:android   屏蔽返回键   屏蔽home键   屏蔽menu键   

public class LockActivity extends Activity{
	private  static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.getWindow().setFlags(FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);//关键代码 
		setContentView(R.layout.activity_main);
		
	}
	@SuppressWarnings("static-access")
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		if(keyCode==event.KEYCODE_BACK){
			return true;
		}
		if(keyCode==event. KEYCODE_HOME){
			return true;
		}
		if(keyCode == KeyEvent.KEYCODE_MENU) {//MENU键
	        //监控/拦截菜单键
	         return true;
	    }     
		return super.onKeyDown(keyCode, event);
	}
}

屏蔽掉返回键,menu键,Home键,布布扣,bubuko.com

屏蔽掉返回键,menu键,Home键

标签:android   屏蔽返回键   屏蔽home键   屏蔽menu键   

原文地址:http://blog.csdn.net/mingyue_1128/article/details/33725047

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!