From f4de1b3de63833e9cead9a850806d6566441b6cc Mon Sep 17 00:00:00 2001 From: CPTProgrammer <46586216+CPTProgrammer@users.noreply.github.com> Date: Thu, 24 Aug 2023 04:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0x-rpc-device=5Fid=E5=AF=B9?= =?UTF-8?q?=E4=BA=8E=E5=AE=89=E5=8D=93=E8=AE=BE=E5=A4=87=E7=9A=84=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- other/authentication.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/other/authentication.md b/other/authentication.md index 4cb3884..4ba0ea1 100644 --- a/other/authentication.md +++ b/other/authentication.md @@ -81,6 +81,20 @@ _注:以下列表只是说明该请求头的值通常在哪些平台出现, 设备ID,由使用的设备决定。 +安卓上一般为一串由`ANDROID_ID`生成的`UUID`,Kotlin 中可以这样获取(Java 同理) +```Kotlin +import android.content.Context +import android.provider.Settings +import java.util.UUID + +@SuppressLint("HardwareIds") +fun getDeviceId(context: Context): String { + val androidId = Settings.Secure.getString(context.contentResolver, Settings.System.ANDROID_ID) + val uuid = UUID.nameUUIDFromBytes(androidId.toByteArray()) + return uuid.toString() +} +``` + #### `X-Requested-With` 国内版APP为`com.mihoyo.hyperion`。