ユーザからのアプリのバグ報告には, そのユーザの環境も欲しい(じゃないと再現確認できませんものね)ので, ユーザの環境を得る方法をメモします.
- ユーザの環境 (Androidのバージョン)
- ユーザの環境 (メーカーとデバイス名)
- アプリのバージョン (versionName)
を それぞれ得ます.
(検索用 英語)
How to know the current OS / platform of the executing code from the Android.OS.Build library in Xamarin
- the system Version of Android
- the Device Model and Manufacturer
- Application Runtime VersionName
as below,
// Android 4.2.2
// Android 5.1.1
var os_ver = "Android"
+ Android.OS.Build.VERSION.Release;
// Sony SO-02F
// Samsung GT-N8010
var device = Android.OS.Build.Manufacturer
+ ' '
+ Android.OS.Build.Model;
// このアプリのバージョン (AndroidManifest.xml の android:versionName に記述してある値)
var context = this.Activity.ApplicationContext; // 今いるのが fragment ではなく Activity だった場合, this.ApplicationContext でOKだと思う
var app_ver = context
.PackageManager
.GetPackageInfo(context.PackageName, 0)
.VersionName;