Android InputMethodManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android InputMethodManager class.

This code example shows how to use the following methods:hideSoftInputFromWindow
This code example shows how to use the following methods:hideSoftInputFromWindow, showSoftInput
     
    @Test 
    public void shouldRecordSoftInputVisibility() { 
        assertThat(shadow.isSoftInputVisible()).isFalse();
    	 
    	manager.showSoftInput(null, 0);
        assertThat(shadow.isSoftInputVisible()).isTrue();
    	 
    	manager.hideSoftInputFromWindow(null, 0);
        assertThat(shadow.isSoftInputVisible()).isFalse();
    }    
} 
7
CodeRank
This code example shows how to use the following methods:hideSoftInputFromWindow
    } 
 
    @Override 
    protected boolean onOkClick() { 
        InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
        return super.onOkClick(); 
    } 
 
    @Override 
    protected void onCancelClick() { 
        super.onCancelClick(); 
        InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
    } 
 
    public boolean hasNotes() { 
        return !TextUtils.isEmpty(editText.getText());
    } 
 
7
CodeRank
This code example shows how to use the following methods:hideSoftInputFromWindow
     /** 
      * Hide the soft keyboard. 
      */ 
     public static void hideKeyboard() { 
         InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
         imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
     } 
 
    /** 
     * Scan WiFi networks 
     */ 
    static List<ScanResult> latestResult;
 
    public static void enableWifiScanner() 
    { 
        IntentFilter i = new IntentFilter();
        i.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
 
        context.registerReceiver(new BroadcastReceiver() {
 
7
CodeRank
This code example shows how to use the following methods:getShortcutInputMethodsAndSubtypes, setInputMethodAndSubtype
     * Switches to Voice IME. 
     */ 
    public void startVoiceRecognition(String language) {
        InputMethodManager inputMethodManager = getInputMethodManager(mInputMethodService);
 
        InputMethodInfo inputMethodInfo = getVoiceImeInputMethodInfo(inputMethodManager);
 
        if (inputMethodInfo == null) {
            return; 
        } 
 
        inputMethodManager.setInputMethodAndSubtype(mInputMethodService.getWindow().getWindow()
                .getAttributes().token,
                inputMethodInfo.getId(),
                getVoiceImeSubtype(inputMethodManager, inputMethodInfo));
    } 
 
    private static InputMethodManager getInputMethodManager(InputMethodService inputMethodService) {
        return (InputMethodManager) inputMethodService
                .getSystemService(Context.INPUT_METHOD_SERVICE);

7
CodeRank
This code example shows how to use the following methods:hideSoftInputFromWindow, isActive
    @Override 
    protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
        super.onFocusChanged(focused, direction, previouslyFocusedRect);
        final InputMethodManager imm = ((InputMethodManager) getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE));
        if (imm != null && imm.isActive(this)) {
            imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
        } 
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent event) {
        final boolean ret = super.onTouchEvent(event);
        // Must be done after super.onTouchEvent() 
        final InputMethodManager imm = ((InputMethodManager) getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE));
        if (imm != null && imm.isActive(this)) {
            imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
        } 
        return ret;
7
CodeRank
This code example shows how to use the following methods:showSoftInput
					handler.post(new Runnable() {
						@Override 
						public void run () { 
							dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
							InputMethodManager input = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
							if (input != null) input.showSoftInput(textView, InputMethodManager.SHOW_FORCED);
						} 
					}); 
 
					final View content = dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
					content.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
						int[] screenloc = new int[2];
						private int keyboardHeight;
						private boolean keyboardShowing;
 
						@Override 
						public boolean onPreDraw () { 
							content.getLocationOnScreen(screenloc);
							keyboardHeight = Math.abs(screenloc[1]);
							if (keyboardHeight > 0) keyboardShowing = true;
6
CodeRank
This code example shows how to use the following methods:hideSoftInputFromWindow
      v.setText("");
 
      InputMethodManager imm=
          (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
 
      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    } 
 
    return(true); 
  } 
 
  private void configureActionItem(Menu menu) {
    EditText add=
        (EditText)menu.findItem(R.id.add).getActionView()
                      .findViewById(R.id.title);
 
    add.setOnEditorActionListener(this);
  } 
 
  private void initAdapter() { 
7
CodeRank
This code example shows how to use the following methods:getResources, getInstance
This code example shows how to use the following methods:isActive
 
	@Override 
	public boolean dispatchKeyEventPreIme ( KeyEvent event ) {
		if ( activityReference != null ) {
			InputMethodManager imm = ( InputMethodManager ) activityReference.getSystemService ( Context.INPUT_METHOD_SERVICE );
			if ( imm.isActive () && event.getKeyCode () == KeyEvent.KEYCODE_BACK ) {
				MoaiLog.i ( "LinearLayoutIMETrap dispatchKeyEventPreIme, event: " + event );
				MoaiKeyboard.hideKeyboard (); // hide the keyboard if its visible .. 
				if ( Moai.backButtonPressed ()) { 
					return true; 
				} 
			} 
		} 
 
		return super.dispatchKeyEventPreIme ( event );
	} 
} 
6
CodeRank

Related Android InputMethodManager Questions & Answers:

Other Android InputMethodManager Examples

68:	
69:						// Hiding the keyboard
70:						InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
71:						imm.hideSoftInputFromWindow(inputLabel.getWindowToken(), 0);
72:	
-
68:	
69:						// Hiding the keyboard
70:						InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
71:						imm.hideSoftInputFromWindow(inputLabel.getWindowToken(), 0);
72:

Read More

See Code Examples for Android InputMethodManager Methods: