facebook twitter hatena line email

「Android/端末情報」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
 
(同じ利用者による、間の6版が非表示)
行5: 行5:
 
     Log.i("test", "carrier=" + carrier); // DOCOMO: 44010 SoftBank: 44020 Au: 44070
 
     Log.i("test", "carrier=" + carrier); // DOCOMO: 44010 SoftBank: 44020 Au: 44070
 
  }
 
  }
 +
 
  // 言語表示
 
  // 言語表示
 
  Locale locale = Locale.getDefault();
 
  Locale locale = Locale.getDefault();
行15: 行16:
 
  // package_name取得(com.example.test.myapplication
 
  // package_name取得(com.example.test.myapplication
 
  Log.i("test", "package_name=" + getApplication().getPackageName().toLowerCase());
 
  Log.i("test", "package_name=" + getApplication().getPackageName().toLowerCase());
+
 
  // 端末名(404KC
+
  // 端末名(KYL22
 
  Log.i("test", Build.MODEL);
 
  Log.i("test", Build.MODEL);
 +
 +
// ua取得
 +
userAgent = (new WebView(context.getApplicationContext())).getSettings().getUserAgentString();
 +
if(userAgent == null) {
 +
    userAgent = "";
 +
}
 +
 +
==端末向き縦横判定==
 +
<pre>
 +
int orientation = getResources().getConfiguration().orientation;
 +
// 横向き
 +
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
 +
}
 +
// 縦向き
 +
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
 +
}
 +
</pre>
 +
https://qiita.com/niusounds/items/74ade5e5a446869dcc8b

2019年5月22日 (水) 18:10時点における最新版

// キャリア判別
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