facebook twitter hatena line google mixi email

Android/端末情報

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
// キャリア判別
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String carrier = tm.getSimOperator();
if (carrier != null && carrier.length() > 0) {
    Log.i("test", "carrier=" + carrier); // DOCOMO: 44010 SoftBank: 44020 Au: 44070
}
// 言語表示
Locale locale = Locale.getDefault();
String language = locale.getLanguage();
String country = locale.getCountry();
Log.i("test", "language=" + language); // ja
Log.i("test", "country=" + country); // JP
Log.i("test", "lang=" + Locale.getDefault().toString()); // ja_JP
// package_name取得(com.example.test.myapplication
Log.i("test", "package_name=" + getApplication().getPackageName().toLowerCase());
// 端末名(KYL22
Log.i("test", Build.MODEL);
// ua取得
userAgent = (new WebView(context.getApplicationContext())).getSettings().getUserAgentString();
if(userAgent == null) {
    userAgent = "";
}

端末向き縦横判定

int orientation = getResources().getConfiguration().orientation;
// 横向き
if (orientation == Configuration.ORIENTATION_LANDSCAPE) { 
}
// 縦向き
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
}

https://qiita.com/niusounds/items/74ade5e5a446869dcc8b