首页 > 解决方案 > 如何在未征得用户许可的情况下从 MIUI 11 上的 Android 键盘 (IME) 启动 Activity?

问题描述

在此处输入图像描述

我无法从键盘启动 Activity,而其他键盘(如“Go Keyboard”、“Microsoft Swiftkey Keyboard”、“1C Big Keyboard”和更多键盘在 MIUI 11 上正常工作,默认权限已在安装时允许)在任何中国手机上。

    final Intent intent = new Intent( mRichImm.getInputMethodInfoOfThisIme().getSettingsActivity());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
        | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
        | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final int currentDisplayId = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
        .getDefaultDisplay().getDisplayId();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    context.startActivity(intent,
            ActivityOptions.makeBasic().setLaunchDisplayId(currentDisplayId).toBundle());
  }else{
    context.startActivity(intent);
  }
}else{
  context.startActivity(intent);
}

在此处输入图像描述

标签: androidimeandroid-input-methodmiui

解决方案


推荐阅读