It's very easy to get the Android UDID - check out the following code:
Attribution:
http://stackoverflow.com/a/10085178/730807
public class DemoActivityActivity extends Activity {For getting the Device ID you have to set following permission in AndroidManifest.xml:
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TelephonyManager tm = (TelephonyManager)
this.getSystemService(Context.TELEPHONY_SERVICE);
Log.d(">>>>", "Android ID: " +Secure.getString(getContentResolver(), Secure.ANDROID_ID));
Log.d(">>>>", "Device ID : " + tm.getDeviceId());
}
}
<android:name="android.permission.READ_PHONE_STATE"/>For getting the Android ID you don't need to set any permission.
Attribution:
http://stackoverflow.com/a/10085178/730807
No comments:
Post a Comment