I want most of my pages to remain still and the android keyboard to go on top of them, so in *AndroidManifest.xml* I have
android:windowSoftInputMode="adjustPan" On one particular page I want the keyboard to push up the content, triggered by a javascript/java bridge in a webview, hence the JavaScriptFunctions class. The toast is purely there to text the interface is working (the toast does appear). pushKeyboard() is called from the javascript inside the webview. *MainActivity.java* public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { . . public static Context cont; protected void onCreate(Bundle savedInstanceState) { . . webView.addJavascriptInterface(new JavaScriptFunctions(), "AndroidNative"); cont = MainActivity.this; // this "works", but is useless because it changes the soft input for the whole application: //getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); } public class JavaScriptFunctions { @JavascriptInterface public void pushKeyboard() { Toast.makeText(MainActivity.this, "Balls.", Toast. LENGTH_LONG).show(); // MainActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); // This gives error "can't reference non-static method from static context" ((Activity)getApplicationContext()).getWindow() .setSoftInputMode(WindowManager. LayoutParams.SOFT_INPUT_ADJUST_RESIZE); // fails // getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); // fails //((Activity)cont).getWindow() // .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); // extreme failure } } } Inside onCreate(), the code does indeed set the soft input mode, but I can't get it working from inside JavaScriptFunctions. I've tried many variations, including creating a Context in MainActivity. How do I get this working? -- 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 android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. 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/672d88c4-d90a-4bd1-9f89-af132496530f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.