LoginSignup
2
0

Android の端末の言語設定をコマンドで変更したい

Last updated at Posted at 2023-07-31

概要

端末の言語設定を毎回手動で変更するのが面倒だったので、楽にできる方法をまとめました。

adb コマンドで設定画面を開いてから言語を変える

adb shell am start -a android.settings.LOCALE_SETTINGS

言語設定画面はメーカーやAndroidのバージョンによって導線が微妙に違ったりするので、これを使うとちょっと楽になるかも。

ドキュメントに書いてある方法

こちらに記載されている方法です。
https://developer.android.com/guide/topics/resources/localization?hl=ja

adb shell
setprop persist.sys.locale fr-CA

のような感じで簡単に変更できそうな感じで書いてありますが、実際に試すと効果はありません。

customlocal2 経由で変更する

adb shell am broadcast -a com.android.intent.action.SET_LOCALE --es com.android.intent.extra.LOCALE "en_US" com.android.customlocale2

API Level 28が提供されていた頃はエミュレーターに com.android.customlocale2 同梱されていたようで、これに対して broadcast intent を投げることで、言語を変更できていたようです。

これもうまくいきません。

adb shell pm list packages | grep locale

で package をチェックしてもないので、同梱されなくなったとものと思われます。

言語を変更するアプリを用意して、それ経由で言語を変更する

言語を変更するAPI自体は用意されているので、それを実行すれば言語を変更することができます。

ただアプリを書くのがめんどくさいので、appium が提供している設定ツールを使ってみることにしました。

release タブから apk をダウンロードして adb install して grant するだけ。簡単。

# アプリに言語を変更する権限が必要なので付与してあげる
adb shell pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION

adb shell am broadcast -a io.appium.settings.locale -n io.appium.settings/.receivers.LocaleSettingReceiver --es lang en --es country US # en_US に変更
adb shell am broadcast -a io.appium.settings.locale -n io.appium.settings/.receivers.LocaleSettingReceiver --es lang ja --es country JP # ja_JP に変更
adb shell am broadcast -a io.appium.settings.locale -n io.appium.settings/.receivers.LocaleSettingReceiver --es lang ar --es country SA # ar-SA に変更


参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0