Java Code Examples for android.view.KeyEvent#KEYCODE_HOME
The following examples show how to use
android.view.KeyEvent#KEYCODE_HOME .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Launcher.java From TurboLauncher with Apache License 2.0 | 6 votes |
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HOME: return true; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HOME: return true; } } return super.dispatchKeyEvent(event); }
Example 2
Source File: AuthenticationErrorActivity.java From product-emm with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { tryAgain(); return true; } else if (keyCode == KeyEvent.KEYCODE_HOME) { finish(); return true; } return super.onKeyDown(keyCode, event); }
Example 3
Source File: AuthenticationActivity.java From product-emm with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); this.startActivity(i); return true; } else if (keyCode == KeyEvent.KEYCODE_HOME) { this.finish(); return true; } return super.onKeyDown(keyCode, event); }
Example 4
Source File: SettingsActivity.java From LaunchTime with GNU General Public License v3.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_HOME || keyCode==KeyEvent.KEYCODE_MENU) { Intent main = new Intent(this, MainActivity.class); startActivity(main); setResult(RESULT_OK); finish(); } return super.onKeyDown(keyCode, event); }
Example 5
Source File: AboutActivity.java From LaunchTime with GNU General Public License v3.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_HOME) { Intent home = new Intent(this, MainActivity.class); startActivity(home); finish(); } else if (keyCode==KeyEvent.KEYCODE_MENU) { Intent sett = new Intent(this, SettingsActivity.class); startActivity(sett); finish(); } return super.onKeyDown(keyCode, event); }
Example 6
Source File: FeedbackActivity.java From LaunchTime with GNU General Public License v3.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_HOME) { Intent home = new Intent(this, MainActivity.class); startActivity(home); finish(); } else if (keyCode==KeyEvent.KEYCODE_MENU) { Intent sett = new Intent(this, SettingsActivity.class); startActivity(sett); finish(); } return super.onKeyDown(keyCode, event); }
Example 7
Source File: AlreadyRegisteredActivity.java From product-emm with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { loadHomeScreen(); return true; } else if (keyCode == KeyEvent.KEYCODE_HOME) { loadHomeScreen(); return true; } else { return super.onKeyDown(keyCode, event); } }
Example 8
Source File: KeyComboManager.java From talkback with Apache License 2.0 | 5 votes |
/** * Returns converted key code. This method converts the following key events. - Convert * KEYCODE_HOME with meta to KEYCODE_ENTER. - Convert KEYCODE_BACK with meta to KEYCODE_DEL. * * @param event Key event to be converted. * @return Converted key code. */ static int getConvertedKeyCode(KeyEvent event) { // We care only when meta key is pressed with. if ((event.getModifiers() & KeyEvent.META_META_ON) == 0) { return event.getKeyCode(); } if (event.getKeyCode() == KeyEvent.KEYCODE_HOME) { return KeyEvent.KEYCODE_ENTER; } else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { return KeyEvent.KEYCODE_DEL; } else { return event.getKeyCode(); } }
Example 9
Source File: AppListActivity.java From product-emm with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { loadHomeScreen(); return true; } else if (keyCode == KeyEvent.KEYCODE_HOME) { loadHomeScreen(); return true; } else { return super.onKeyDown(keyCode, event); } }
Example 10
Source File: SplashActivity.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
/** * 开屏页最好禁止用户对返回按钮的控制 */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) { return true; } return super.onKeyDown(keyCode, event); }
Example 11
Source File: StartActivity.java From Alibaba-Android-Certification with MIT License | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) { return true; } return super.onKeyDown(keyCode, event); }
Example 12
Source File: SplashActivity.java From NewsMe with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) { return true; } return super.onKeyDown(keyCode, event); }
Example 13
Source File: Lock.java From Pi-Locker with GNU General Public License v2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_APP_SWITCH || keyCode == KeyEvent.KEYCODE_SOFT_LEFT || keyCode == KeyEvent.KEYCODE_SOFT_RIGHT; }
Example 14
Source File: KeyPressedTipViewController.java From timecat with Apache License 2.0 | 5 votes |
@Override public void run() { Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(10); isLongPressedCancel = currentKeyCode == KeyEvent.KEYCODE_BACK; if (currentKeyCode == KeyEvent.KEYCODE_HOME) { isLongPressedHome = true; } if (currentKeyCode == KeyEvent.KEYCODE_APP_SWITCH) { isLongPressedRecent = true; } KeyPressedTipViewController.getInstance().show(null); }
Example 15
Source File: LockActivity.java From TapUnlock with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_HOME) { activityManager.moveTaskToFront(taskId, 0); return true; } return false; }
Example 16
Source File: AuthenticationErrorActivity.java From product-emm with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { tryAgain(); return true; } else if (keyCode == KeyEvent.KEYCODE_HOME) { finish(); return true; } return super.onKeyDown(keyCode, event); }
Example 17
Source File: KeyboardShortcutDialogPreference.java From talkback with Apache License 2.0 | 5 votes |
private boolean processKeyEvent(KeyEvent event) { if (event == null) { return false; } if (event.getRepeatCount() > 1) { return false; } //noinspection SimplifiableIfStatement if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_HOME || event.getKeyCode() == KeyEvent.KEYCODE_CALL || event.getKeyCode() == KeyEvent.KEYCODE_ENDCALL) { return false; } // Enter and Esc are used to accept/dismiss dialogs. However, the default shortcuts // involve Enter and Esc (with modifiers), so we should only trap Enter and Esc without // modifiers. boolean isDialogNavigation = event.getKeyCode() == KeyEvent.KEYCODE_ENTER || event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE; if (isDialogNavigation && event.hasNoModifiers()) { return false; } return event.getAction() == KeyEvent.ACTION_DOWN; }
Example 18
Source File: MainActivity.java From xpay with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_BACK){ keyCode = KeyEvent.KEYCODE_HOME; } return super.onKeyDown(keyCode, event); }
Example 19
Source File: BtnsNavbar.java From XposedNavigationBar with GNU General Public License v3.0 | 4 votes |
@Override protected void longHome() { KeyEvent keyEvent = new KeyEvent(KeyEvent.FLAG_LONG_PRESS, KeyEvent.KEYCODE_HOME); mInst.sendKeySync(keyEvent); }
Example 20
Source File: AbsDokitView.java From DoraemonKit with Apache License 2.0 | 4 votes |
/** * 执行floatPage create * * @param context 上下文环境 */ @SuppressLint("ClickableViewAccessibility") void performCreate(Context context) { try { //调用onCreate方法 onCreate(context); if (!isNormalMode()) { DokitViewManager.getInstance().addDokitViewAttachedListener(this); } if (isNormalMode()) { mRootView = new DokitFrameLayout(context); } else { //系统悬浮窗的返回按键监听 mRootView = new DokitFrameLayout(context) { @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && shouldDealBackKey()) { //监听返回键 if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_HOME) { return onBackPressed(); } } return super.dispatchKeyEvent(event); } }; } //添加根布局的layout回调 addViewTreeObserverListener(); //调用onCreateView抽象方法 mChildView = onCreateView(context, mRootView); //将子View添加到rootview中 mRootView.addView(mChildView); //设置根布局的手势拦截 mRootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getRootView() != null) { return mTouchProxy.onTouchEvent(v, event); } else { return false; } } }); //调用onViewCreated回调 onViewCreated(mRootView); mDokitViewLayoutParams = new DokitViewLayoutParams(); //分别创建对应的LayoutParams if (isNormalMode()) { mFrameLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); mFrameLayoutParams.gravity = Gravity.LEFT | Gravity.TOP; mDokitViewLayoutParams.gravity = Gravity.LEFT | Gravity.TOP; } else { mWindowLayoutParams = new WindowManager.LayoutParams(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { //android 8.0 mWindowLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { mWindowLayoutParams.type = WindowManager.LayoutParams.TYPE_PHONE; } if (!shouldDealBackKey()) { //参考:http://www.shirlman.com/tec/20160426/362 //设置WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE会导致rootview监听不到返回按键的监听失效 mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mDokitViewLayoutParams.flags = DokitViewLayoutParams.FLAG_NOT_FOCUSABLE; } mWindowLayoutParams.format = PixelFormat.TRANSPARENT; mWindowLayoutParams.gravity = Gravity.LEFT | Gravity.TOP; mDokitViewLayoutParams.gravity = Gravity.LEFT | Gravity.TOP; //动态注册关闭系统弹窗的广播 IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.registerReceiver(mInnerReceiver, intentFilter); } initDokitViewLayoutParams(mDokitViewLayoutParams); if (isNormalMode()) { onNormalLayoutParamsCreated(mFrameLayoutParams); } else { onSystemLayoutParamsCreated(mWindowLayoutParams); } } catch (Exception e) { LogHelper.e(TAG, "e===>" + e.getMessage()); e.printStackTrace(); } }