Unique Android Device ID after MarshMallow warning "get device identifiers is not recommended"?
<p>I saw one of my best question <a href="https://stackoverflow.com/q/2785485/1318946"><strong>Is there a unique Android device ID?</strong></a></p>

<h2>Edited:</h2>

<p><strong>I need a solution for Android 10 too.</strong></p>

<p>I used some following code to get Unique Id.</p>

<pre><code>public static String getDeviceId(Activity context) {

    PermissionsChecker checker = new PermissionsChecker(context);

    if (checker.lacksPermissions(Manifest.permission.READ_PHONE_STATE))
        PermissionsActivity.startActivityForResult(context, 0, REQUIRED_PERMISSION);
    else {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        final String tmDevice = tm.getDeviceId();
        final String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);

        UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() &lt;&lt; 32));

        return deviceUuid.toString();
    }
    return null;
}
</code></pre>

<p>But I am getting some warning on hover on</p>

<p><code>tm.getDeviceId();</code> </p>

<p>and</p>

<p><code>Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);</code> 
as following:</p>

<blockquote>
  <p>Using <strong>getString</strong> to get device identifiers is not recommended.</p>
  
  <p>Using device identifiers is not recommended other than for high value
  fraud prevention and advanced telephony use-cases. For advertising
  use-cases, use <code>AdvertisingIdClient$Info#getId</code> and for analytics, use
  <code>InstanceId#getId.</code></p>
</blockquote>

<p>Is there any solution? Is it harmful or anything else?</p>