I'm trying to perform a choose default keyboard operation on long key press 
of SPACE key in my soft-keyboard. Why is its not working. Any new logic are 
most welcome but the x,y touch coordinate one.

This is my current logic  

package bedesi.whatskeys;

import android.content.Context;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.text.method.MetaKeyKeyListener;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;

public class WhatsKeys extends InputMethodService implements 
KeyboardView.OnKeyboardActionListener{

    @Override public boolean onKeyDown(int keyCode, KeyEvent event) {
        
    if(keyCode == KeyEvent.KEYCODE_SPACE)
    {
    event.startTracking();
    return true;
    }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub

    if(keyCode == KeyEvent.KEYCODE_SPACE){
    InputMethodManager imm = 
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showInputMethodPicker();
    return true;
    }
    return super.onKeyLongPress(keyCode, event);
    }

    
    @Override public boolean onKeyUp(int keyCode, KeyEvent event) {
        
        return super.onKeyUp(keyCode, event);
    }

    
    private void keyDownUp(int keyEventCode) {
        getCurrentInputConnection().sendKeyEvent(
                new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode));
        getCurrentInputConnection().sendKeyEvent(
                new KeyEvent(KeyEvent.ACTION_UP, keyEventCode));
    }

}

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/912fd5cc-3d06-481c-9c98-4efd661abe86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to