1

<intent android:action="android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS"/> does not work anymore. I found an answer here.

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

But the problem is that I need to find the equivalent code to launch this intent through XML. Is this possible?

Community
  • 1
  • 1
Aaron
  • 1,256
  • 11
  • 16
  • Note that your approach may not work on all devices, as there is no requirement for there to be an exported `com.android.settings.LanguageSettings` activity in an app named `com.android.settings`. – CommonsWare Jan 28 '16 at 18:07
  • Is there any other way to launch that intent? – Aaron Jan 28 '16 at 18:09
  • Well, there is no guaranteed way to do it in general. `ACTION_INPUT_METHOD_SETTINGS` works as well now as it ever has, as it is [still in the manifest as of Android 6.0](https://android.googlesource.com/platform/packages/apps/Settings/+/master/AndroidManifest.xml). You need to accept the fact that you cannot guarantee any way to get to that activity, and so doing it from what I assume is preference XML is not going to work well. From Java, you can see if the `Intent` resolves to anything and gracefully degrade if you cannot find a way to that activity. – CommonsWare Jan 28 '16 at 18:15

1 Answers1

1

Nevermind I found an answer here. Since

android:targetClass

Is the class part of the component name, as per the setComponent() method. and

android:targetPackage 

The package part of the component name, as per the setComponent() method.

and also according to this,

ComponentName(String package, String class)

So the equivalent XML code for this is:

<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.LanguageSettings" />

Although just like Mr.CommonsWare said, It is not advisable to use this method (Read his comment to my original post). But for those who still want to use this method, go ahead. Hope this helps :)

Community
  • 1
  • 1
Aaron
  • 1,256
  • 11
  • 16