android - 如何在未征得用户许可的情况下从 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);
}
解决方案
推荐阅读
- android - Android - ARCore:如何区分检测到的飞机?
- matlab - 为什么 condition2 condition3 和 condition4 double 不合逻辑?
- auth0 - TypeError,未定义的“摘要”,在开发环境中
- java - Gretty,从存储库设置“模块指定的库”
- javascript - 如何比较两个字符串,其中一个带有反引号
- sql-server - 通过动态sql多次执行TSQL批处理
- c# - 限制用户不输入小数
- postgresql - Helm 部署:在 Cloud SQL 中将 Kubernetes 连接到 Postgres DB
- nativescript - 使用 NativeScript 在 Android 上移除 TextFields 的边框底部
- node.js - 将调度作业添加到 nodejs 微服务最佳实践