So I'm trying to get the IMEI # of android devices using a headless fragment. After doing some research, turns out there're a few ways to go about this.
Mainly, most of the methods I've come across use this in different contexts
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();
A couple of notes I found are that permissions have changed on Android M. Permissions are now requested at runtime as opposed to install time previous to Android M. Also, to my understanding dual SIM phones have 2 unique IMEI numbers, correct?
So I have a couple of questions. First, can I achieve the same results if I were to use a dial method (dialing *#06#)? And if so, would it work on both dual & single SIM phones? If this works, it would eliminate asking the user for permission at runtime (I think it's inconvenient) and require much less code. If feasible, can I implement this using headless fragments instead of an activity? How?
If the above approach doesn't work, how can I achieve this while checking if the phone runs a single or dual SIM using headless fragment?