Get device's Android ID

Secure.ANDROID_ID is a 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.)

device's Android ID


package com.example.androidid;

import android.os.Bundle;
import android.provider.Settings.Secure;
import android.app.Activity;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

String id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
Toast.makeText(getApplicationContext(), id, Toast.LENGTH_LONG).show();
}

}


0 Response to "Get device's Android ID"

Posting Komentar