如何获取我的注册ID设备

9

我需要发送安卓推送通知,需要什么(就像iOS一样,我需要设备UDID来发送简单的推送通知)?

如果我需要获取我的设备的注册ID,我该如何获取它?

谢谢。


你只能发送设备 ID,而不能发送注册 ID。 - Aerrow
我尝试使用注册ID,它可以工作,但是我找不到如何使用设备ID发送推送通知。所以你有相关链接吗? - abdel
1个回答

1

您需要这个吗?

public static String getDeviceID(Context context) {
    final TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);

    final String tmDevice, tmSerial, tmPhone, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "";// + tm.getSimSerialNumber();
    androidId = ""
            + android.provider.Settings.Secure.getString(
                    context.getContentResolver(),
                    android.provider.Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(),
            ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String deviceId = deviceUuid.toString();

    return deviceId;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接