Android-如何覆盖“Back”按钮,这样它就不会完成我的活动?
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (Integer.parseInt(android.os.Build.VERSION.SDK) < 5 && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { Log.d("CDA", "onKeyDown Called"); onBackPressed(); } return super.onKeyDown(keyCode, event); } public void onBackPressed() { Log.d("CDA", "onBackPressed Called"); Intent setIntent = new Intent(Intent.ACTION_MAIN); setIntent.addCategory(Intent.CATEGORY_HOME); setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(setIntent); return; }
侃侃尔雅
慕斯王
潇湘沐
相关分类