List of usage examples for android.view KeyEvent KEYCODE_HOME
int KEYCODE_HOME
To view the source code for android.view KeyEvent KEYCODE_HOME.
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
/** * this function work by permission.//from ww w .j a v a 2s. c o m */ public static void pressHome() { new Thread(new Runnable() { @Override public void run() { Instrumentation m_Instrumentation = new Instrumentation(); m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); } }).start(); }
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); }/* w w w . j av a2s . c o m*/ } return navigationBarHeight; }
From source file:com.google.android.car.kitchensink.input.InputTestFragment.java
@Nullable @Override/* ww w . j a va2s . c om*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.input_test, container, false); Collections.addAll(mButtons, BREAK_LINE, createButton(R.string.home, KeyEvent.KEYCODE_HOME), createButton(R.string.volume_up, KeyEvent.KEYCODE_VOLUME_UP), createButton(R.string.volume_down, KeyEvent.KEYCODE_VOLUME_DOWN), createButton(R.string.volume_mute, KeyEvent.KEYCODE_VOLUME_MUTE), createButton(R.string.voice, KeyEvent.KEYCODE_VOICE_ASSIST), BREAK_LINE, createButton(R.string.music, KeyEvent.KEYCODE_MUSIC), createButton(R.string.music_play, KeyEvent.KEYCODE_MEDIA_PLAY), createButton(R.string.music_stop, KeyEvent.KEYCODE_MEDIA_STOP), createButton(R.string.next_song, KeyEvent.KEYCODE_MEDIA_NEXT), createButton(R.string.prev_song, KeyEvent.KEYCODE_MEDIA_PREVIOUS), createButton(R.string.tune_right, KeyEvent.KEYCODE_CHANNEL_UP), createButton(R.string.tune_left, KeyEvent.KEYCODE_CHANNEL_DOWN), BREAK_LINE, createButton(R.string.call_send, KeyEvent.KEYCODE_CALL), createButton(R.string.call_end, KeyEvent.KEYCODE_ENDCALL)); mCarEmulator = CarEmulator.create(getContext()); addButtonsToPanel((LinearLayout) view.findViewById(R.id.input_buttons), mButtons); return view; }
From source file:Main.java
public static String getKeyNameByCode(int code) { switch (code) { case KeyEvent.KEYCODE_0: return "<0>"; case KeyEvent.KEYCODE_1: return "<1>"; case KeyEvent.KEYCODE_2: return "<2>"; case KeyEvent.KEYCODE_3: return "<3>"; case KeyEvent.KEYCODE_4: return "<4>"; case KeyEvent.KEYCODE_5: return "<5>"; case KeyEvent.KEYCODE_6: return "<6>"; case KeyEvent.KEYCODE_7: return "<7>"; case KeyEvent.KEYCODE_8: return "<8>"; case KeyEvent.KEYCODE_9: return "<9>"; case KeyEvent.KEYCODE_A: return "<A>"; case KeyEvent.KEYCODE_B: return "<B>"; case KeyEvent.KEYCODE_C: return "<C>"; case KeyEvent.KEYCODE_D: return "<D>"; case KeyEvent.KEYCODE_E: return "<E>"; case KeyEvent.KEYCODE_F: return "<F>"; case KeyEvent.KEYCODE_G: return "<G>"; case KeyEvent.KEYCODE_H: return "<H>"; case KeyEvent.KEYCODE_I: return "<I>"; case KeyEvent.KEYCODE_J: return "<J>"; case KeyEvent.KEYCODE_K: return "<K>"; case KeyEvent.KEYCODE_L: return "<L>"; case KeyEvent.KEYCODE_M: return "<M>"; case KeyEvent.KEYCODE_N: return "<N>"; case KeyEvent.KEYCODE_O: return "<O>"; case KeyEvent.KEYCODE_P: return "<P>"; case KeyEvent.KEYCODE_Q: return "<Q>"; case KeyEvent.KEYCODE_R: return "<R>"; case KeyEvent.KEYCODE_S: return "<S>"; case KeyEvent.KEYCODE_T: return "<T>"; case KeyEvent.KEYCODE_U: return "<U>"; case KeyEvent.KEYCODE_V: return "<V>"; case KeyEvent.KEYCODE_W: return "<W>"; case KeyEvent.KEYCODE_X: return "<X>"; case KeyEvent.KEYCODE_Y: return "<Y>"; case KeyEvent.KEYCODE_Z: return "<Z>"; case KeyEvent.KEYCODE_APOSTROPHE: return "<'>"; case KeyEvent.KEYCODE_AT: return "<@>"; case KeyEvent.KEYCODE_BACK: return "<Back>"; case KeyEvent.KEYCODE_BACKSLASH: return "<\\>"; case KeyEvent.KEYCODE_CALL: return "<Call>"; case KeyEvent.KEYCODE_CAMERA: return "<Camera>"; case KeyEvent.KEYCODE_CLEAR: return "<Clear>"; case KeyEvent.KEYCODE_COMMA: return "<,>"; case KeyEvent.KEYCODE_DEL: return "<Del>"; case KeyEvent.KEYCODE_DPAD_CENTER: return "<PadCenter>"; case KeyEvent.KEYCODE_DPAD_DOWN: return "<PadDown>"; case KeyEvent.KEYCODE_DPAD_LEFT: return "<PadLeft>"; case KeyEvent.KEYCODE_DPAD_RIGHT: return "<PadRight>"; case KeyEvent.KEYCODE_DPAD_UP: return "<PadUp>"; case KeyEvent.KEYCODE_ENDCALL: return "<EndCall>"; case KeyEvent.KEYCODE_ENTER: return "<Enter>"; case KeyEvent.KEYCODE_ENVELOPE: return "<Envelope>"; case KeyEvent.KEYCODE_EQUALS: return "<=>"; case KeyEvent.KEYCODE_EXPLORER: return "<Explorer>"; case KeyEvent.KEYCODE_FOCUS: return "<??? 0>"; case KeyEvent.KEYCODE_GRAVE: return "<??? 1>"; case KeyEvent.KEYCODE_HEADSETHOOK: return "<??? 2>"; case KeyEvent.KEYCODE_HOME: return "<Home>"; case KeyEvent.KEYCODE_LEFT_BRACKET: return "<(>"; case KeyEvent.KEYCODE_MENU: return "<Menu>"; case KeyEvent.KEYCODE_MINUS: return "<->"; case KeyEvent.KEYCODE_NOTIFICATION: return "<??? 3>"; case KeyEvent.KEYCODE_NUM: return "<Num>"; case KeyEvent.KEYCODE_PERIOD: return "<??? 4>"; case KeyEvent.KEYCODE_PLUS: return "<+>"; case KeyEvent.KEYCODE_POUND: return "<??? 5>"; case KeyEvent.KEYCODE_POWER: return "<Power>"; case KeyEvent.KEYCODE_RIGHT_BRACKET: return "<)>"; case KeyEvent.KEYCODE_SEMICOLON: return "<;>"; case KeyEvent.KEYCODE_SLASH: return "</>"; case KeyEvent.KEYCODE_SOFT_LEFT: return "<??? 6>"; case KeyEvent.KEYCODE_SOFT_RIGHT: return "<??? 7>"; case KeyEvent.KEYCODE_SPACE: return "<Space>"; case KeyEvent.KEYCODE_STAR: return "<*>"; case KeyEvent.KEYCODE_SYM: return "<Sym>"; case KeyEvent.KEYCODE_TAB: return "<Tab>"; case KeyEvent.KEYCODE_VOLUME_DOWN: return "<VolumeDown>"; case KeyEvent.KEYCODE_VOLUME_UP: return "<VolumeUp>"; case KeyEvent.KEYCODE_UNKNOWN: default:/*from www . j a v a2 s . co m*/ return "<Unknown>"; } }
From source file:com.gigaset.home.Home.java
/** * Catch keys to avoid back through HOME in Back Stack *///from w ww . j a v a 2 s .c o m @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: return true; case KeyEvent.KEYCODE_HOME: return true; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: if (!event.isCanceled()) { // Do BACK behavior. } return true; case KeyEvent.KEYCODE_HOME: if (!event.isCanceled()) { // Do HOME behavior. myPager.setCurrentItem(HomePagerAdapter.SCREEN_CENTER); } return true; } } return super.dispatchKeyEvent(event); }
From source file:com.smartcodeunited.demo.bluetooth.activity.BaseActivity.java
/** * If there is a virtual buttons, may have a miscalculation * * @return/* w w w. jav a 2s.co m*/ */ private boolean hasNavigationBar() { boolean hasMenuKey = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { hasMenuKey = ViewConfiguration.get(this).hasPermanentMenuKey(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Display d = getWindowManager().getDefaultDisplay(); DisplayMetrics realDisplayMetrics = new DisplayMetrics(); d.getRealMetrics(realDisplayMetrics); int realHeight = realDisplayMetrics.heightPixels; int realWidth = realDisplayMetrics.widthPixels; DisplayMetrics displayMetrics = new DisplayMetrics(); d.getMetrics(displayMetrics); int displayHeight = displayMetrics.heightPixels; int displayWidth = displayMetrics.widthPixels; return realWidth > displayWidth || realHeight > displayHeight; } boolean hasPhysicsBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); boolean hasPhysicsHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME); if (hasPhysicsBackKey && hasPhysicsHomeKey) { return false; } else { return true; } }
From source file:com.perm.DoomPlay.FullPlaybackActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_HOME)) { finish();//from ww w . ja v a 2s . c o m } return super.onKeyDown(keyCode, event); }
From source file:com.volosyukivan.WiFiInputMethod.java
void receivedKey(int code, boolean pressed) { if (code == KeyboardHttpServer.FOCUS) { for (int key : pressedKeys) { sendKey(key, false, false);/*from ww w . ja v a 2s. co m*/ } pressedKeys.clear(); resetModifiers(); return; } if (pressedKeys.contains(code) == pressed) { if (pressed == false) return; // ignore autorepeat on following keys switch (code) { case KeyEvent.KEYCODE_ALT_LEFT: case KeyEvent.KEYCODE_SHIFT_LEFT: case KeyEvent.KEYCODE_HOME: case KeyEvent.KEYCODE_MENU: return; } } if (pressed) { pressedKeys.add(code); sendKey(code, pressed, false); } else { pressedKeys.remove(code); sendKey(code, pressed, pressedKeys.isEmpty()); } }
From source file:com.launcher.silverfish.launcher.LauncherActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // Override the functionality of back and home key if ((keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) && event.getRepeatCount() == 0) { event.startTracking();/*from ww w . j a v a 2s .co m*/ return true; } return super.onKeyDown(keyCode, event); }