Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何禁用输入选择通知android_Android_Keyboard_Android Softkeyboard_Android Input Method_Custom Keyboard - Fatal编程技术网

如何禁用输入选择通知android

如何禁用输入选择通知android,android,keyboard,android-softkeyboard,android-input-method,custom-keyboard,Android,Keyboard,Android Softkeyboard,Android Input Method,Custom Keyboard,我已经创建了一个自定义软键盘,我希望设备中的所有应用程序仅使用此键盘。我添加了密码限制以访问输入选择设置页面。问题是当有多个软键盘可用时,会出现通知。是否有任何方法可以禁用此输入选择通知或限制用户选择其他键盘。我想分享我自己的问题答案,以便它可以帮助面临相同问题的其他人。 我在窗口顶部添加了一个自定义视图,这样状态栏就可以避免触摸事件。下面是我的代码 public class ClearStatusBar extends Service { private WindowManager

我已经创建了一个自定义软键盘,我希望设备中的所有应用程序仅使用此键盘。我添加了密码限制以访问输入选择设置页面。问题是当有多个软键盘可用时,会出现通知。是否有任何方法可以禁用此输入选择通知或限制用户选择其他键盘。

我想分享我自己的问题答案,以便它可以帮助面临相同问题的其他人。 我在窗口顶部添加了一个自定义视图,这样状态栏就可以避免触摸事件。下面是我的代码

public class ClearStatusBar extends Service {

    private WindowManager mWindowManager;
    private NotificationManager mNotificationManager;
    private static View statusbar;



 @Override
public void onCreate() {
    super.onCreate();
    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

}


 private WindowManager.LayoutParams getWindowManagerParams() {
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ERROR ,
             // Keeps the button presses from going to the background window
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                // Enables the notification to recieve touch events
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
                // Draws over status bar
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                PixelFormat.TRANSLUCENT); // must be translucent to support KitKat gradient
        params.gravity = Gravity.TOP;
        params.x=0;
        int statusBarHeight = getStatusBarHeight();
        params.height = (statusBarHeight>25?statusBarHeight:25);
        return params;
    }

 public int getStatusBarHeight() {
      int result = 0;
      int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
      if (resourceId > 0) {
          result = getResources().getDimensionPixelSize(resourceId);
      }
      return result;
}



@Override
public IBinder onBind(Intent intent) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if(statusbar == null){
        statusbar = new View(this);
        statusbar.setBackgroundColor(Color.parseColor("#20000000"));
        mWindowManager.addView(statusbar, getWindowManagerParams());
        if(statusbar != null){
            statusbar.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
        }
    }

    return START_STICKY;
}

@Override
public void onDestroy() {
    if(statusbar != null){
        mWindowManager.removeView(statusbar);
        statusbar = null;
    }
    super.onDestroy();

}

}