开发者

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

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜