首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >隐藏储物柜应用程序的软键盘

隐藏储物柜应用程序的软键盘
EN

Stack Overflow用户
提问于 2015-04-22 18:30:35
回答 4查看 340关注 0票数 17

我正在尝试关闭在其他应用程序中打开的软键盘。我尝试了这里的所有解决方案:Programmatically Hide/Show Android Soft KeyboardClose/hide the Android Soft Keyboard

正如你在图片中看到的,我不得不关闭从另一个应用程序打开的键盘,添加清单以使键盘不可见并没有起到作用。

要注意这是一个储物柜应用程序,我会在手机进入睡眠模式时启动一个活动。

我是不是漏掉了什么?正在测试商店中的其他储物柜应用程序,未遇到此问题

但结果如下:

编辑:更多信息

这是我启动储物柜的方式:

if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
    //Toast.makeText(context, "" + "screeen off", Toast.LENGTH_SHORT).show();

    wasScreenOn = false;
    Intent intent = new Intent(context, LockScreenActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    context.startActivity(intent);

    // do whatever you need to do here
    //wasScreenOn = false;
} 

这是清单代码:

<activity
    android:name=".ui.activities.LockScreenActivity"
    android:excludeFromRecents="true"
    android:noHistory="true"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="stateAlwaysHidden|adjustNothing"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2015-06-04 19:08:46

我终于解决了这个问题。下面是我的活动清单代码:

<activity
        android:name=".ui.activities.LockScreenActivity"
        android:excludeFromRecents="true"
        android:noHistory="true"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden"
        android:configChanges="keyboardHidden"
        android:launchMode="singleInstance"
        android:multiprocess="false"
        android:stateNotNeeded="true"
        android:taskAffinity=""
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
票数 0
EN

Stack Overflow用户

发布于 2015-04-30 20:01:11

它可以覆盖此活动的onPause(),并使用以下代码作为

@Override
public void onPause() {
    super.onPause();
    if (null != getWindow()){
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    }
}
票数 2
EN

Stack Overflow用户

发布于 2015-05-01 13:31:24

在你的活动中试试这个:

private void hideKeyboard() {   
    // Check if no view has focus:
    View view = this.getCurrentFocus();
    if (view != null) {
        InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29794757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档