List of usage examples for android.view KeyEvent KEYCODE_BACK
int KEYCODE_BACK
To view the source code for android.view KeyEvent KEYCODE_BACK.
Click Source Link
From source file:Main.java
public static boolean canUseKey(int keyCode) { return ((keyCode != KeyEvent.KEYCODE_BACK) && (keyCode != KeyEvent.KEYCODE_HOME) && (keyCode != KeyEvent.KEYCODE_MENU) && (keyCode != KeyEvent.KEYCODE_ENDCALL)); }
From source file:Main.java
public static void shutdownActivity() { Runtime runtime = Runtime.getRuntime(); try {/*from w w w . ja v a 2s . c o m*/ runtime.exec("input keyevent " + KeyEvent.KEYCODE_BACK); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:Main.java
public static int getNavigationBarHeight(Context c) { int result = 0; boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (!hasMenuKey && !hasBackKey) { //The device has a navigation bar Resources resources = c.getResources(); int orientation = resources.getConfiguration().orientation; int resourceId; if (isTablet(c)) { resourceId = resources//from w ww . j a v a 2 s . co m .getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); } else { resourceId = resources .getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android"); } if (resourceId > 0) { return resources.getDimensionPixelSize(resourceId); } } return result; }
From source file:Main.java
public static int getNavigationBarHeight(Context context) { int navigationBarHeight = 0; boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME); if (!hasBackKey && !hasHomeKey) { // 99% sure there is a navigation bar Resources resources = context.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigationBarHeight = resources.getDimensionPixelSize(resourceId); }//from w w w . j a v a 2 s . c o m } return navigationBarHeight; }
From source file:Main.java
public static boolean checkDeviceHasNavigationBar(Context context) { boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (!hasMenuKey && !hasBackKey) { return true; }//w w w .j ava 2 s. c o m return false; }
From source file:Main.java
private static int getNavBarHeight(Context context) { boolean hasMenuKey = Build.VERSION.SDK_INT >= 14 && ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); boolean hasNavBar = !hasMenuKey && !hasBackKey; if (hasNavBar) { boolean isPortrait = context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isTablet = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; String key = isPortrait ? "navigation_bar_height" : (isTablet ? "navigation_bar_height_landscape" : null); return key == null ? 0 : getDimenSize(context, key); } else {//w w w . j a va2 s . c o m return 0; } }
From source file:Main.java
public static boolean onKeyBackGoHome(Activity activity, int keyCode, KeyEvent event) { if (!(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)) { return false; // continue }/* ww w . j a va2 s . co m*/ activity.startActivity(new Intent().setAction(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); return true; }
From source file:Main.java
/** * Check the device whether has soft navigation bar *///from w ww .ja v a 2 s . c om public static boolean hasNavigationBar(Context context) { Resources resources = context.getResources(); int id = resources.getIdentifier("config_showNavigationBar", "bool", "android"); if (id > 0) { return resources.getBoolean(id); } else { // Check for keys boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); return !hasMenuKey && !hasBackKey; } }
From source file:com.farmerbb.taskbar.widget.StartMenuLayout.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (viewHandlesBackButton && event.getKeyCode() == KeyEvent.KEYCODE_BACK) { LocalBroadcastManager.getInstance(getContext()) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); return true; }//from w w w . j av a2s. c o m return super.dispatchKeyEvent(event); }
From source file:com.app.khclub.base.easeim.activity.BaseActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { finish();/*from w w w .ja v a2 s . c o m*/ overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); return true; } else return super.onKeyDown(keyCode, event); }