3

I'm studying mandarin and want to change the language of my Android smartphone (Sony Xperia) between english/mandarin (or english/mandarin/portuguese/spanish) faster than using the default system settings. The way it is, I have to enter settings, scroll to the middle of it (which is slower than if it was on the beginning or end of the list), click Language & input, click language, have to scroll all the way down to 中文 (it should already be at the top, among the "recently used languages", but only my native language is always there), click 中文 and finally click ok.

I would like to reduce those 6+ clicks to a single button in the quick settings area (there is space for 4 more icons): when the phone is in a language, a tap on the icon would change to the next language, holding the icon would open a menu to add/remove languages/change order/etc.

I'm new to Android development, so I don't know if it's possible for an app to change the system language (need root privileges? I want it for myself, even if I won't be allowed to share it on Google Play, for instance). I've seen many answers on how to change an app language, that's not what I'm looking for. I also found many apps in Google Play, all of them promising to "quick toggle system language" etc, but none of them worked on my device. The closest I got was this, but looks like a dead thread.

So, is it possible? If so, where is the documentation?

Community
  • 1
  • 1
Rodrigo
  • 4,706
  • 6
  • 51
  • 94

1 Answers1

1

I think this is what you might looking for!!!

If you would like to have your own application you can try this app i just created for you here!!!

Language Picker Widget

The Java Code

public class MainActivity extends Activity {
    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn = (Button)findViewById(R.id.add_button);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //in the line below it tells it to go to the language selection list
                Intent intent = new Intent(Settings.ACTION_LOCALE_SETTINGS);
                startActivity(intent);
                MainActivity.this.finish();


            }
        });
    }

}

The Layout File

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Change System Language"
        android:id="@+id/add_button"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>

You can start a project in eclipse, use the codes above for the activity and the layout and then test it on the emulator

Kostas Drak
  • 3,222
  • 6
  • 28
  • 60
  • I could install the Language Picker Widget, but it crashes as soon as I click on the icon (a white square with the name of the language in black). The same has happened before with other widget. I'll look for your app. Thanks for the help! – Rodrigo Dec 20 '14 at 04:28
  • What file should I open to compile it in Eclipse? – Rodrigo Dec 20 '14 at 04:32
  • you dont have to open eclipse at all....you install it on your smartphone directly – Kostas Drak Dec 20 '14 at 04:37
  • did my app help you??at least it reduces the clicks – Kostas Drak Dec 20 '14 at 04:52
  • Since I wanna learn both, mandarin and programming to Android, I'm trying to test your app in the emulator first and see how it works. – Rodrigo Dec 20 '14 at 05:04
  • it just has a button that takes you directly to the list of languages in the settings app with a single click without having to go all the way from the settings – Kostas Drak Dec 20 '14 at 05:33
  • well, can you tell me where is the code that does this, in those 277 itens inside the .apk? – Rodrigo Dec 20 '14 at 06:19
  • I added "private Button btn;" Also, "btn = (Button)findViewById(R.id.add_button);" gave me "add_button cannot be resolved or is not a field" – Rodrigo Dec 21 '14 at 03:04
  • post all the code in your activity and layout file. as you can see in my answer the button in the layout has the same id i call in the onCreate method so try to have the same id – Kostas Drak Dec 21 '14 at 03:26
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/67399/discussion-between-kostasmatrix-and-rodrigo). – Kostas Drak Dec 21 '14 at 03:27