Home
Unlabelled
Get device's Android ID
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.)
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 komentar:
Posting Komentar