当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.KEYCODE_SEARCH属性代码示例

本文整理汇总了Java中android.view.KeyEvent.KEYCODE_SEARCH属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_SEARCH属性的具体用法?Java KeyEvent.KEYCODE_SEARCH怎么用?Java KeyEvent.KEYCODE_SEARCH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEYCODE_SEARCH属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	switch (keyCode) {
       case KeyEvent.KEYCODE_VOLUME_DOWN:
       case KeyEvent.KEYCODE_VOLUME_UP:
       	
       	if(speakerAmplification != null) {
       		int step = (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)? - 1 : + 1;
       		int newValue = speakerAmplification.getProgress() + step;
       		if(newValue >= 0 && newValue < speakerAmplification.getMax()) {
       			speakerAmplification.setProgress(newValue);
       		}
       	}
       	
       	
       	return true;
       case KeyEvent.KEYCODE_CALL:
	case KeyEvent.KEYCODE_ENDCALL:
	case KeyEvent.KEYCODE_SEARCH:
		//Prevent search
		return true;
       default:
       	//Nothing to do	
	}
	return super.onKeyDown(keyCode, event);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:26,代码来源:InCallMediaControl.java

示例2: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_MENU: {
            if (drawer.isDrawerOpen()) {
                drawer.closeDrawer();
            } else {
                drawer.openDrawer();
            }
            return true;
        }
        case KeyEvent.KEYCODE_SEARCH: {
            startActivity(new Intent(this, SearchActivity.class));
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:18,代码来源:MainActivity.java

示例3: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
	switch (keyCode) {
	case KeyEvent.KEYCODE_VOLUME_DOWN:
	case KeyEvent.KEYCODE_VOLUME_UP:
	case KeyEvent.KEYCODE_CALL:
	case KeyEvent.KEYCODE_ENDCALL:
	case KeyEvent.KEYCODE_SEARCH:
		return true;
	}
	return super.onKeyUp(keyCode, event);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:InCallMediaControl.java

示例4: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    Log.d(THIS_FILE, "Key up : " + keyCode);
    switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_CALL:
        case KeyEvent.KEYCODE_SEARCH:
            return true;
        case KeyEvent.KEYCODE_ENDCALL:
            return inCallAnswerControls.onKeyDown(keyCode, event);

    }
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:15,代码来源:InCallActivity.java

示例5: onKeyDown

/**
 * Catch the SEARCH key so that the general Android TV search is not launched.
 * Try to relaunch the movie name search instead
 * @param keyCode
 * @param event
 * @return
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
        Fragment f = getFragmentManager().findFragmentById(R.id.fragment);
        if (f instanceof SearchFragment) {
            ((SearchFragment)f).startRecognition();
            return true;
        }
    }
    return super.onKeyDown(keyCode, event); // default
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:18,代码来源:ManualVideoScrappingActivity.java

示例6: onKeyDown

/**
 * Catch the SEARCH key to launch our search instead of the Android TV general search
 * @param keyCode
 * @param event
 * @return
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
        Intent intent = new Intent(this, VideoSearchActivity.class);
        intent.putExtra(VideoSearchActivity.EXTRA_SEARCH_MODE, VideoSearchActivity.SEARCH_MODE_ALL);
        startActivity(intent);
        return true;
    }
    return super.onKeyDown(keyCode, event); // default
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:16,代码来源:LeanbackActivity.java

示例7: onKeyDown

/**
 * Catch the SEARCH key so that the general Android TV search is not launched.
 * Try to relaunch the AVP search instead
 * @param keyCode
 * @param event
 * @return
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
        Fragment f = getFragmentManager().findFragmentById(R.id.video_search_fragment);
        if (f instanceof SearchFragment) {
            ((SearchFragment)f).startRecognition();
            return true;
        }
    }
    return super.onKeyDown(keyCode, event); // default
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:18,代码来源:VideoSearchActivity.java

示例8: onKeyDown

/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app.
 */
@Override public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            // The InputMethodService already takes care of the back
            // key for us, to dismiss the input method if it is shown.
            // However, our keyboard could be showing a pop-up window
            // that back should dismiss, so we first allow it to do that.
            if (event.getRepeatCount() == 0 && mInputView != null) {
                if (mInputView.handleBack()) {
                    return true;
                }
            }
            break;
            
        case KeyEvent.KEYCODE_DEL:
            // Special handling of the delete key: if we currently are
            // composing text for the user, we want to modify that instead
            // of let the application to the delete itself.
            if (mComposing.length() > 0) {
                onKey(Keyboard.KEYCODE_DELETE, null);
                return true;
            }
            break;
            
        case KeyEvent.KEYCODE_ENTER:
            // Let the underlying text editor always handle these.
            return false;

        case KeyEvent.KEYCODE_SEARCH: // google samples of how this one is used
            return true;

        default:
            break;
    }
    
    return super.onKeyDown(keyCode, event);
}
 
开发者ID:cdjalel,项目名称:QuranKeyboard,代码行数:42,代码来源:QuranKeyboardIME.java

示例9: onDispatchKeyEvent

@Override
public Boolean onDispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    boolean isBackButton = keyCode == KeyEvent.KEYCODE_BACK;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (isBackButton && mCustomView != null) {
            return true;
        } else if (boundKeyCodes.contains(keyCode)) {
            return true;
        } else if (isBackButton) {
            return engine.canGoBack();
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        if (isBackButton && mCustomView != null) {
            hideCustomView();
            return true;
        } else if (boundKeyCodes.contains(keyCode)) {
            String eventName = null;
            switch (keyCode) {
                case KeyEvent.KEYCODE_VOLUME_DOWN:
                    eventName = "volumedownbutton";
                    break;
                case KeyEvent.KEYCODE_VOLUME_UP:
                    eventName = "volumeupbutton";
                    break;
                case KeyEvent.KEYCODE_SEARCH:
                    eventName = "searchbutton";
                    break;
                case KeyEvent.KEYCODE_MENU:
                    eventName = "menubutton";
                    break;
                case KeyEvent.KEYCODE_BACK:
                    eventName = "backbutton";
                    break;
            }
            if (eventName != null) {
                sendJavascriptEvent(eventName);
                return true;
            }
        } else if (isBackButton) {
            return engine.goBack();
        }
    }
    return null;
}
 
开发者ID:Andy-Ta,项目名称:COB,代码行数:45,代码来源:CordovaWebViewImpl.java

示例10: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.d(THIS_FILE, "Key down : " + keyCode);
    switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
            //
            // Volume has been adjusted by the user.
            //
            Log.d(THIS_FILE, "onKeyDown: Volume button pressed");
            int action = AudioManager.ADJUST_RAISE;
            if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                action = AudioManager.ADJUST_LOWER;
            }

            // Detect if ringing
            SipCallSession currentCallInfo = getActiveCallInfo();
            // If not any active call active
            if (currentCallInfo == null && serviceConnected) {
                break;
            }

            if (service != null) {
                try {
                    service.adjustVolume(currentCallInfo, action, AudioManager.FLAG_SHOW_UI);
                } catch (RemoteException e) {
                    Log.e(THIS_FILE, "Can't adjust volume", e);
                }
            }

            return true;
        case KeyEvent.KEYCODE_CALL:
        case KeyEvent.KEYCODE_ENDCALL:
            return inCallAnswerControls.onKeyDown(keyCode, event);
        case KeyEvent.KEYCODE_SEARCH:
            // Prevent search
            return true;
        default:
            // Nothing to do
    }
    return super.onKeyDown(keyCode, event);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:42,代码来源:InCallActivity.java

示例11: onSuggestionsKey

/**
 * React to the user typing while in the suggestions list. First, check for
 * action keys. If not handled, try refocusing regular characters into the
 * EditText.
 */
private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions (late arrival after dismiss)
    if (mSearchable == null) {
        return false;
    }
    if (mSuggestionsAdapter == null) {
        return false;
    }
    if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) {
        // First, check for enter or search (both of which we'll treat as a
        // "click")
        if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH
                || keyCode == KeyEvent.KEYCODE_TAB) {
            int position = mQueryTextView.getListSelection();
            return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null);
        }

        // Next, check for left/right moves, which we use to "return" the
        // user to the edit view
        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            // give "focus" to text editor, with cursor at the beginning if
            // left key, at end if right key
            // TODO: Reverse left/right for right-to-left languages, e.g.
            // Arabic
            int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView
                    .length();
            mQueryTextView.setSelection(selPoint);
            mQueryTextView.setListSelection(0);
            mQueryTextView.clearListSelection();
            ensureImeVisible(mQueryTextView, true);

            return true;
        }

        // Next, check for an "up and out" move
        if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) {
            // TODO: restoreUserQuery();
            // let ACTV complete the move
            return false;
        }

        // Next, check for an "action key"
        // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
        // TODO if ((actionKey != null)
        // TODO         && ((actionKey.getSuggestActionMsg() != null) || (actionKey
        // TODO                 .getSuggestActionMsgColumn() != null))) {
        // TODO     // launch suggestion using action key column
        // TODO     int position = mQueryTextView.getListSelection();
        // TODO     if (position != ListView.INVALID_POSITION) {
        // TODO         Cursor c = mSuggestionsAdapter.getCursor();
        // TODO         if (c.moveToPosition(position)) {
        // TODO             final String actionMsg = getActionKeyMessage(c, actionKey);
        // TODO             if (actionMsg != null && (actionMsg.length() > 0)) {
        // TODO                 return onItemClicked(position, keyCode, actionMsg);
        // TODO             }
        // TODO         }
        // TODO     }
        // TODO }
    }
    return false;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:66,代码来源:SearchView.java

示例12: dispatchKeyEvent

/**
 * This should be called from the Activity's dispatchKeyEvent() to handle keyboard shortcuts.
 *
 * Note: dispatchKeyEvent() is called before the active view or web page gets a chance to handle
 * the key event. So the keys handled here cannot be overridden by any view or web page.
 *
 * @param event The KeyEvent to handle.
 * @param activity The ChromeActivity in which the key was pressed.
 * @param uiInitialized Whether the UI has been initialized. If this is false, most keys will
 *                      not be handled.
 * @return True if the event was handled. False if the event was ignored. Null if the event
 *         should be handled by the activity's parent class.
 */
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
public static Boolean dispatchKeyEvent(KeyEvent event, ChromeActivity activity,
        boolean uiInitialized) {
    int keyCode = event.getKeyCode();
    if (!uiInitialized) {
        if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_MENU) return true;
        return null;
    }

    switch (keyCode) {
        case KeyEvent.KEYCODE_SEARCH:
            if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
                activity.onMenuOrKeyboardAction(R.id.focus_url_bar, false);
            }
            // Always consume the SEARCH key events to prevent android from showing
            // the default app search UI, which locks up Chrome.
            return true;
        case KeyEvent.KEYCODE_MENU:
            if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
                activity.onMenuOrKeyboardAction(R.id.show_menu, false);
            }
            return true;
        case KeyEvent.KEYCODE_ESCAPE:
            if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
                if (activity.exitFullscreenIfShowing()) return true;
            }
            break;
        case KeyEvent.KEYCODE_TV:
        case KeyEvent.KEYCODE_GUIDE:
        case KeyEvent.KEYCODE_DVR:
        case KeyEvent.KEYCODE_AVR_INPUT:
        case KeyEvent.KEYCODE_AVR_POWER:
        case KeyEvent.KEYCODE_STB_INPUT:
        case KeyEvent.KEYCODE_STB_POWER:
        case KeyEvent.KEYCODE_TV_INPUT:
        case KeyEvent.KEYCODE_TV_POWER:
        case KeyEvent.KEYCODE_WINDOW:
            // Do not consume the AV device-related keys so that the system will take
            // an appropriate action, such as switching to TV mode.
            return false;
    }

    return null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:57,代码来源:KeyboardShortcuts.java

示例13: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
    // If back key
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // A custom view is currently displayed  (e.g. playing a video)
        if(mCustomView != null) {
            this.hideCustomView();
            return true;
        } else {
            // The webview is currently displayed
            // If back key is bound, then send event to JavaScript
            if (isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK)) {
                sendJavascriptEvent("backbutton");
                return true;
            } else {
                // If not bound
                // Go to previous page in webview if it is possible to go back
                if (this.backHistory()) {
                    return true;
                }
                // If not, then invoke default behavior
            }
        }
    }
    // Legacy
    else if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (this.lastMenuEventTime < event.getEventTime()) {
            sendJavascriptEvent("menubutton");
        }
        this.lastMenuEventTime = event.getEventTime();
        return super.onKeyUp(keyCode, event);
    }
    // If search key
    else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        sendJavascriptEvent("searchbutton");
        return true;
    }

    //Does webkit change this behavior?
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:42,代码来源:CordovaWebView.java


注:本文中的android.view.KeyEvent.KEYCODE_SEARCH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。