Using API 25 on an emulator:
adb shell settings put secure android_id 8af8770a27cfd182
adb shell settings get secure android_id //gives 8af8770a27cfd182
Secure.getString(context.getContentResolver(), Secure.ANDROID_ID) //gives 8af8770a27cfd182
Using API 26 on an emulator:
adb shell settings put secure android_id 8af8770a27cfd182
adb shell settings get secure android_id //gives 8af8770a27cfd182
Secure.getString(context.getContentResolver(), Secure.ANDROID_ID) //gives 6e4f84f5513b80e1
I've read about the changes of ANDROID_ID between API 25 and 26 but why is adb and code giving me different results for it?
UPDATE:
Created a simple app to take out the complexity of the old one. New app has a single main activity with a button on it:
package com.example.diolaj01.testandroidid;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
protected void GetAndroidId(View view){
Log.e("myDebugTag", Settings.Secure.getString(view.getContext().getContentResolver(),
Settings.Secure.ANDROID_ID));
}
}
When clicking the button on a device with API 25 I get the same value as when requesting the ANDROID_ID from adb:
adb shell settings get secure android_id
If I change the android_id I still get the updated one in both the console using the button and using adb.
When clicking the button on a device with API 26 I get a different value than the one I get when using adb. If I change the android_id using adb I'll get the updated value when using adb but not using the button.