小编Taz*_*azz的帖子

隐藏更衣柜应用的软键盘

我正在尝试关闭在另一个应用程序中打开的软键盘.我从这里尝试了所有解决方案:以 编程方式隐藏/显示Android软键盘或此处:关闭/隐藏Android软键盘

正如你在图片中看到我必须关闭从另一个应用程序打开的键盘,添加到清单,不要让键盘可见不起作用.

要注意这是一个更衣室应用程序,我会在手机进入睡眠模式时启动一项活动.

我错过了什么吗?从商店测试其他更衣室应用程序并没有遇到此问题

但结果如下:

应用程序打开键盘 我的应用

编辑:更多信息

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

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;
} 
Run Code Online (Sandbox Code Playgroud)

这是清单代码:

<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" />
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard

17
推荐指数
1
解决办法
321
查看次数

阻止/禁用最近的应用按钮

我知道这个问题在此之前被问过Android禁用最近的任务按钮,就像在SureLock中一样,但由于答案没有用,所以也许有些人可以分享这个被遗忘的事情.

我也尝试过:

private void closeRecents() {
     activ.sendBroadcast(new Intent("com.android.systemui.recent.action.CLOSE"));
     Intent closeRecents = new Intent("com.android.systemui.recent.action.TOGGLE_RECENTS");
     closeRecents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
     ComponentName recents = new ComponentName(SYSTEM_UI_PACKAGE_NAME, RECENTS_ACTIVITY);
     closeRecents.setComponent(recents);
     activ.startActivity(closeRecents);
}
Run Code Online (Sandbox Code Playgroud)

但没有运气

android android-navigation

13
推荐指数
2
解决办法
4万
查看次数

从状态列表drawable获取特定的drawable

我有一个状态列表drawable,我想从状态列表drawable得到一个特定的drawable:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:kplus="http://schemas.android.com/apk/res-auto">


    <item kplus:key_type_space_alt="true" android:state_pressed="true" android:drawable="@drawable/space_1_pressed" />
    <item kplus:key_type_space_alt="true" android:drawable="@drawable/space_1_normal" />

    <!-- TopNav keys. -->

    <item kplus:key_type_topnav="true" android:state_pressed="true" android:drawable="@drawable/tab_down" />
    <item kplus:key_type_topnav="true" android:state_selected="true" android:drawable="@drawable/tab_down" />
    <item kplus:key_type_topnav="true" android:drawable="@drawable/tab_normal" />

    <!-- TopRow keys. -->

    <item kplus:key_type_toprow="true" android:state_pressed="true" android:drawable="@drawable/numeric_presseed" />
    <item kplus:key_type_toprow="true" android:drawable="@drawable/numeric_normal" />
</selector>
Run Code Online (Sandbox Code Playgroud)

我为每个键选择了正确的可绘制状态,如下所示:

if (keyIsNumbers) {
    if (KPlusInputMethodService.sNumbersState == 2) {
        drawableState = mDrawableStatesProvider.KEY_STATE_TOPNAV_CHECKED;
    }
}
Run Code Online (Sandbox Code Playgroud)

现在状态定义如下:

KEY_STATE_TOPNAV_NORMAL = new int[] {keyTypeTopNavAttrId};
KEY_STATE_TOPNAV_PRESSED = new int[] {keyTypeTopNavAttrId, android.R.attr.state_pressed};
KEY_STATE_TOPNAV_CHECKED = new int[] {keyTypeTopNavAttrId, android.R.attr.state_selected}; …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-input-method statelistdrawable android-drawable

10
推荐指数
1
解决办法
6145
查看次数

Android - 当Android 5.0(棒棒糖)键盘启动时调整scrollview

我在android棒棒糖上遇到问题,当软键盘出现时,屏幕不会调整大小.

这是我所做的一项活动的明显介绍示例:

android:windowSoftInputMode="stateAlwaysHidden|adjustResize" 
Run Code Online (Sandbox Code Playgroud)

是否有新的东西被添加,我们必须考虑到Android 5.0?scrollview在android <5.0上运行正常.

android android-manifest android-layout android-softkeyboard android-scrollview

7
推荐指数
2
解决办法
3318
查看次数

通过按钮以编程方式模拟拍照,就像通过蓝牙使用自拍杆一样

所以我有一个蓝牙设备,我听设备上的按钮按下,并尝试在按下按钮时拍照。问题是我没有找到任何解决方案来做到这一点。

} else if (destination.equals(APPLICATION_ACTION_DESTINATION_OPEN_CAMERA)) {
    Intent intent1 = new Intent("android.intent.action.CAMERA_BUTTON");
    intent1.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(0, KeyEent.KEYCODE_CAMERA));
    context.sendOrderedBroadcast(intent1, null);

    intent1 = new Intent("android.intent.action.CAMERA_BUTTON");
    intent1.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(1, KeyEvent.KEYCODE_CAMERA));
    context.sendOrderedBroadcast(intent1, null);
} else if (destination.equals(APPLICATION_ACTION_DESTINATION_TAKE_PHOTO)) {

}
Run Code Online (Sandbox Code Playgroud)

我发现做到这一点的唯一方法是使用:

Instrumentation.sendKeyDownUpSync();
Run Code Online (Sandbox Code Playgroud)

问题是我需要注册 INJECT_EVENTS 权限,该权限仅授予系统应用程序。

有人设法做到这一点吗?

android android-intent android-camera android-event android-bluetooth

5
推荐指数
1
解决办法
2694
查看次数