Trying to put this
https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibility#ShowOnStart
into the mainfest file, but intellij tells me:
and
any suggestions ?
Trying to put this
https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibility#ShowOnStart
into the mainfest file, but intellij tells me:
and
any suggestions ?
I don't think you can do that. The activity tag must contain the activity name. For example Screen1. But we can't edit the values ββfor built-in activities in the extension, we can only add new activities. You can achieve this by just editing the manifest of the compiled APK and adding the entry for the activity you need.
Someone more familiar with programming would need to issue a PR modifying the behavior of adding entries to the Manifest. If someone wants to add a new property with the name of an activity that already exists, e.g. Screen1, then they should append the property to the existing activity or replace the property if it already exists.
Instead, you can try showing the keyboard after starting the application in the initialize block.
OK, many thanks.
Possible to do something similar with a Simple Function or Property with "window.SoftInputMode=" ?
But you want to open the keyboard without any focus? Just open the app and have the keyboard not close?
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Where activity is:
Activity activity = container.$context();
Thanks
Just been building and testing a small extension, which is supposed to prevent the soft keyboard appearing on textbox focus. Unfortunately the keyboard appears. perhaps I need more ?
package uk.co.metricrat.hidesoftkeyboard;
import android.app.*;
import android.content.*;
import android.view.*;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
public class HideSoftKeyboard extends AndroidNonvisibleComponent {
private ComponentContainer container;
private Context context;
private Activity activity;
public HideSoftKeyboard(ComponentContainer container) {
super(container.$form());
this.container = container;
context = (Context) container.$context();
activity = (Activity) context;
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
}
Maybe try for a given texBox:
textBox.getView().setInputType(InputType.TYPE_NULL);
Yes, I have that method, but was going for glory with a global attempt
I think this will hide or show the keyboard only when the activity is started.
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
I found another method but I don't know if it will work, except that it will turn off the focus.
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
Well done Patryk
This actually seems to work (of course difficult to test whether the textbox will still accept input, because it turns off the keyboard ) but I could paste test in there.
Let's throw this at the target developer who has an external scanner with keys (not recognised as an external keyboard - which would hide the keyboard by default)
If the text field does not take focus, then I think the external keyboard will not know which text field to send the text to.
It gets a cursor, so it gets something...
Not able to compile in RUSH, unless I add a "dummy" function ? Other way ?
package uk.co.metricrat.hidesoftkeyboard;
import android.app.*;
import android.content.*;
import android.view.*;
import com.google.appinventor.components.annotations.SimpleFunction;;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
public class HideSoftKeyboard extends AndroidNonvisibleComponent {
private ComponentContainer container;
private Context context;
private Activity activity;
public HideSoftKeyboard(ComponentContainer container) {
super(container.$form());
this.container = container;
context = (Context) container.$context();
activity = (Activity) context;
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}
@SimpleFunction()
public final String DummyIgnore() {
return "true";
}
}
What error does it show? Maybe rush has a minimum requirement of one block. What if you remove @SimpleFunction annotations? You can mark this empty function as Depracated, then it won't be visible. Maybe move to Fast, because Rush is no longer supported. It hasn't been updated for a long time.
That worked, thank you.
@Deprecated
@SimpleFunction()
public final String DummyIgnore() {
return "true";
}
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.