「Xamarin.AndroidでUUIDを生成取得する」の版間の差分
imported>Administrator |
編集の要約なし |
||
| (2人の利用者による、間の2版が非表示) | |||
| 3行目: | 3行目: | ||
[[リセマラ]]対応[[ゲーム]]などを作るときはこれ。 | [[リセマラ]]対応[[ゲーム]]などを作るときはこれ。 | ||
<source> | <source lang="csharp"> | ||
public class Installation | |||
{ | |||
public static string _uuid; | |||
public const string INSTALLATION = "INSTALLATION"; | |||
public static string GetUUID(Context context) | |||
{ | { | ||
if (_uuid == null) | |||
{ | { | ||
if ( | var installationFilePath = Path.Combine(context.FilesDir.AbsolutePath, INSTALLATION); | ||
if (!File.Exists(installationFilePath)) | |||
{ | { | ||
_uuid = System.Guid.NewGuid().ToString(); | |||
File.WriteAllText(installationFilePath, _uuid); | |||
} | } | ||
_uuid = File.ReadAllText(installationFilePath); | |||
} | } | ||
return _uuid; | |||
} | } | ||
} | |||
</source> | </source> | ||
== 関連項目 == | == 関連項目 == | ||
* [[Xamarin.AndroidでAndroid IDを取得する]] | * [[Xamarin.AndroidでAndroid IDを取得する]] | ||
* [[Xamarin.Androidでインテントを受け取る]] | |||
[[category: Xamarin.Android]] | [[category: Xamarin.Android]] | ||