title: How to set cursor position in softkeyboard(not in EditText or TextView!!!) in Android?
body: <p>The following code works for only 1000 characters. If there are more than 1000 characters, the cursor will jump back to the end of 999 characters and start working again.</p>
  
  <p>This is because <code>getTextBeforeCursor(n,flag)</code> can offer only the <code>n</code> number of characters before the current cursor position. In EditText, however, we can get all the text by using <code>getText()</code> method and we can get the length as well. But how to get length of the entire text in the composing text area so that I can set the cursor position to anywhere I want.</p>
  
  <pre><code>InputConnection ic = getCurrentInputConnection();
  ic = getCurrentInputConnection();
  
  String str = ic.getTextBeforeCursor(1000,0).toString();
  ic.setSelection(str.length()-1,str.length()-1);
  </code></pre>