Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the deviceId of my Android emulator?

I am developing an android app which can able to get push notifications. But I need to have a deviceId to make it successful and as I don't have any android phone, I used to test the app in emulator. So my question is, can I get a deviceId for my emulator.

like image 477
Chandra Sekhar Avatar asked Jan 07 '12 12:01

Chandra Sekhar


2 Answers

you can't get device id in android but you can get IMEI number for push notification. bcoz all devices has different IMEI number. In Emulator you get by default 0000000000000 As your IMEI but in device you get perfect number. below is the code to get IMEI number

TelephonyManager telephonyManager1 = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager1.getDeviceId();
like image 143
Harsh Trivedi Avatar answered Oct 31 '22 07:10

Harsh Trivedi


The command 'adb devices' also lists the active emulators, which can give the device id.

like image 21
Deepak Avatar answered Oct 31 '22 07:10

Deepak