Fred
Fred

Reputation: 1

Fail to display IMEI using code snippet

When I dial *#06# on my phone the IMEI is displayed. Fine.

But when I use this kind of code :

String imei="*#06#";
Intent cintent= new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+Uri.encode(imei)));
startActivity(cintent);

(or ACTION_CALL instead of ACTION_DIAL)

... the USSD code is displayed correctly on the dialer (*#06#). But even if I click call the IMEI never shows up (error : "Connection problem or invalid MMI code").

I've been through other similar topics, but found no solution and can't figure how to make it work (my phone is running Android 4.4.4).

Note that I don't want to get the result of the USSD, just have it executed somehow.If it is possible...

Thanks for your help !

Upvotes: 0

Views: 448

Answers (1)

Manmohan Badaya
Manmohan Badaya

Reputation: 2336

We have a different way to get IMEI of device . you can follow the link(possible duplicate).How can I get phone serial number (IMEI)

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();

And you should add the following permission into your Manifest.xml file:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

Upvotes: 1

Related Questions