android-input-method

Creating custom keyboard for android

不羁的心 提交于 2019-12-06 16:03:01
问题 Well, you might have seen few questions like asking for this. But reading all of those questions/answers and almost all of the android inputmethod webpages in Google, I am still in trouble. My final goal is to create a custom keyboard. But of course, mine will have special input methods for certain language. But this time, all I want is to show my custom view when the keyboard is popped up. I've managed to pop the default layout based on a qwerty.xml file, which is something like this. xml

Calling InputMethodManager.setInputMethod(IBinder token, String id) outside the InputMethodService. Where to find token?

纵然是瞬间 提交于 2019-12-06 02:59:44
I want to show Google Voice Typing IME on my EditText by clicking on Button. So, according to this article and source code I should write this code inputMethodManager.setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) The problem is: where to find appropriate token. In the source code I saw this mInputMethodService.getWindow().getWindow().getAttributes().token It works great, but this code located in InputMetodService superclass, so it has access to InputMethodService instance. But i don't (unfortunately :) ). Please tell me if you have any suggestions. Thanks. NOT

Embedding emoji(emoticons images) to custom softkeyboard android

和自甴很熟 提交于 2019-12-05 18:48:26
I have created a custom soft Keyboard(IME) where we can add custom emoji. Whenever i try to add my emoticons to it. it override the last text entered. i mean it dont append the emoticons unless it override it. how can i add emoji to currentInputConnection for example i image write hello image abcimage ///where image represents emoji it becomes i image write hello image image // and i can add image after space easily or i can repeatedly add images easily . when i add text it appends to emoji but when i add emoji after entering some text it remove the text and then add it self(emoji image). Just

permission denied when I try to startService

谁说胖子不能爱 提交于 2019-12-05 17:32:28
I am trying to access an InputMethodService from an Activity , and I am running into issues with the permissions. This is for a custom keyboard app. What I am trying to achieve is to bind the text, which is created in the Activity back into the InputMethodService . The Activity is opened from the InputMethodService , then from the Activity , I try to start the Service (which may be the issue. Here is how I open the Activity from the InputMethodService : @Override public void onStartInputView(EditorInfo attribute, boolean restarting) { super.onStartInputView(attribute, restarting); Intent

Why android InputMethodManager.showSoftInput() returns false?

為{幸葍}努か 提交于 2019-12-05 03:39:59
Recently while developing an app, I faced an issue. I have searched a lot on google but couldn't find any solution. In the end I came across this Android issue tracker To explain my issue, I have made a sample App. Basic Working of my Sample App I have a screen, which has an EditText, a Button and a RelativeLayout. Width and Height of RelativeLayout is 0px. It is just a view to move focus away from EditText. When App is launched focus is on RelativeLayout, not on EditText(so that there is not blinking cursor in it.) When a user clicks on Button I just move focus to RelativeLayout using

Close/hide the Android Soft Keyboard on activity state onStop

只愿长相守 提交于 2019-12-05 03:02:38
I have an EditText and a Button in my layout. After writing in the edit field and click this button to go back my fragment , I want to hide the virtual keyboard. I assume that there's a simple, but i tried some way and it not work: That code show how the Button work: private void onButtonClicked(){ getActivity().getSupportFragmentManager().popBackStack(); } That code for some solution but that can't help. This code i using hideSoftInputFromWindow but when i call 'EditText.getWindowToken()', it not hide the soft keyboard (I also change the 0 value to InputMethodManager.HIDE_IMPLICIT_ONLY or

How to detect gesture over ImageView?

。_饼干妹妹 提交于 2019-12-04 20:19:58
I'd like to detect finger being dragged over ImageView. I get my ImageView, create instances of GestureDetector and View.OnTouchListener, then set View.OnTouchListener to ImageView. OnTouchListener detects all touches ("touch occured") and I pass them to GestureDetector, but it never calls its methods onScroll or onFling. What I am doing wrong? Bellow you can see related source: myImageView = (ImageView) findViewById(R.id.imageView1); myGestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { // TODO Auto

Android: Non-Keyboard IME

瘦欲@ 提交于 2019-12-04 11:42:36
问题 Im trying to create an IME for android that is not a traditional keyboard (rows of keys corresponding to the different letters) and I am having trouble finding helpful resources on how to do so since all of the code examples in the SDK use a Keyboard API and it's built in functions. I've designed the interface of the IME in an XML file as though it were simply an Activity within in application but I'm getting lost in their demos since their Keyboards are simply objects that are built from a

Better way to get all the text in an EditText from an InputConnection?

泄露秘密 提交于 2019-12-03 09:26:44
问题 I've written an IME (InputMethodService) and I need to get all the text from the EditText it is editing. I know one way: InputConnection inputConnection = getCurrentInputConnection(); inputConnection.append(inputConnection.getTextBeforeCursor(9999, 0)) .append(inputConnection.getTextAfterCursor(9999, 0)); It works, but it seems pretty stupid and clunky. However there is no such method InputConnection.getText() . Is there a better way? P.S. I cannot access the EditText from my IME because it

How do I change the input method programatically?

。_饼干妹妹 提交于 2019-12-03 08:46:59
I have a requirement of changing the keyboard based on the change of language. I have done a bit of research and found that it can be done using these APIs InputMethodManager setInputMethod(android.os.IBinder, java.lang.String) InputMethodService switchInputMethod(java.lang.String) For the 1st API, I need an IBinder token which can be taken from InputMethodService instance by calling mInputMethodService.getWindow().getWindow().getAttributes().token or if I have the reference to InputMethodService object I can simply call mInputMethodService.switchInputMethod(id) to change the input method. The