check Handset Locale : Settings « Core Class « Android

check Handset Locale

import java.util.Locale;

import android.content.Context;
import android.provider.Settings;
import android.telephony.TelephonyManager;

public class Utils {
  private static final String TAG = "Utils";

  public static Locale checkHandsetLocale(Context ctx) {
    boolean EMULATOR = false;

    // Disable this block to disable EMULATOR use of this app (enabling is
    // useful for testing)
    EMULATOR = (Settings.Secure.getString(ctx.getContentResolver(),
        android.provider.Settings.Secure.ANDROID_ID) == null);

    Locale locale = Locale.getDefault();
    String lo = locale.getCountry().toLowerCase();
    // Check country: show network country is not the same as locale country
    TelephonyManager mTelephonyMgr = (TelephonyManager) ctx
    String country = mTelephonyMgr.getNetworkCountryIso().toLowerCase();
    if (country.matches(lo) && !EMULATOR)
      return locale;


Related examples in the same category

1.get Unique ID from android.provider.Settings.Secure.ANDROID_ID