android.settings.INPUT_METHOD_SETTINGS 不适用于 HTC Hero
我的应用程序有一个按钮,可将用户发送到区域设置。 我使用以下代码执行此操作:
startActivity(new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS));
这在某些设备上运行良好,但在 HTC Hero 上我得到:
02-03 13:59:27.501: INFO/ActivityManager(69): Starting activity: Intent { action=android.settings.INPUT_METHOD_SETTINGS flags=0x10000000 }
02-03 13:59:27.531: DEBUG/AndroidRuntime(1916): Shutting down VM
02-03 13:59:27.531: WARN/dalvikvm(1916): threadid=3: thread exiting with uncaught exception (group=0x40013140)
02-03 13:59:27.531: ERROR/AndroidRuntime(1916): Uncaught handler: thread main exiting due to uncaught exception
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): android.content.ActivityNotFoundException: No Activity found to handle Intent { action=android.settings.INPUT_METHOD_SETTINGS flags=0x10000000 }
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1529)
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1499)
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Activity.startActivityForResult(Activity.java:2669)
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Activity.startActivity(Activity.java:2713)
编辑: 解决方案!
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
ComponentName com = new ComponentName("com.android.settings", "com.android.settings.LanguageSettings");
intent.setComponent(com); startActivity(intent);
前面的代码适用于所有设备:)
My application has a button that sends the user to the locale setting.
I do this with this code:
startActivity(new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS));
This works fine with some devices, but with the HTC Hero I get:
02-03 13:59:27.501: INFO/ActivityManager(69): Starting activity: Intent { action=android.settings.INPUT_METHOD_SETTINGS flags=0x10000000 }
02-03 13:59:27.531: DEBUG/AndroidRuntime(1916): Shutting down VM
02-03 13:59:27.531: WARN/dalvikvm(1916): threadid=3: thread exiting with uncaught exception (group=0x40013140)
02-03 13:59:27.531: ERROR/AndroidRuntime(1916): Uncaught handler: thread main exiting due to uncaught exception
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): android.content.ActivityNotFoundException: No Activity found to handle Intent { action=android.settings.INPUT_METHOD_SETTINGS flags=0x10000000 }
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1529)
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1499)
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Activity.startActivityForResult(Activity.java:2669)
02-03 13:59:27.611: ERROR/AndroidRuntime(1916): at android.app.Activity.startActivity(Activity.java:2713)
EDIT:
SOLUTION!
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
ComponentName com = new ComponentName("com.android.settings", "com.android.settings.LanguageSettings");
intent.setComponent(com); startActivity(intent);
The previous code will work on every device :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
官方的说法是,你可能无法修复它。 HTC 显然用您正在运行的特定 Hero 固件破坏了 SDK。您可以使用
android.os.Build
来识别您正在使用Hero并禁用导致startActivity()
调用失败的任何选项(例如,禁用尝试打开这些设置)。非官方地,尝试通过“设置”应用程序手动进入该屏幕,并查看 LogCat 输出。您可以通过这种方式确定一个可以触发您所寻找的特定屏幕(如果存在)的 Intent。
Officially, you probably cannot fix it. HTC apparently broke the SDK with the particular Hero firmware you are running. You can use
android.os.Build
to identify that you are on a Hero and disable whatever option leads to the failingstartActivity()
call (e.g., disable the menu choice that tries to open up these settings).Unofficially, try going to that screen manually via the Settings application, and take a look at the LogCat output. You might be able to determine that way an Intent that can trigger the specific screen you seek, if one exists.