android.settings.INPUT_METHOD_SETTINGS doesn't work with HTC hero

╄→гoц情女王★ 提交于 2019-12-08 10:17:31

问题


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 :)


回答1:


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 failing startActivity() 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.



来源:https://stackoverflow.com/questions/2192419/android-settings-input-method-settings-doesnt-work-with-htc-hero

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!