Hi. I understand that a Native Extension is needed to get the IMEI or UDID of the Android device. I found one here:
I ran the compiled sample this site provided and it retrieved my IMEI fine, so I know it works.
However, the code for this sample is in Flex. When I tried to incorporate it into my Flash CS6 .fla it didn't work. There were no errors, but when I ran in on the Android device nothing happened when I clicked on the button to retrieve the IMEI. I don't know what went wrong. Here is what I did:
1. First, I imported the "IMEI.ane" file using the steps below:
2. Then in my AIR 3.2 for Android settings I included the "IMEI.ane" file in the publish General settings.
3. In my program there is a textbox and a button. When the button is clicked with a mouse, it calls the function below and places the returned string in the textbox. I know the string to textbox part works, however, when I call the function below it doesn't.
private function mGetImei():String
var tImeiStr:String = " ";
var obj:DeviceStats = Deviceimei.deviceimei.deviceinfo();
tImeiStr = obj.imei.toString();
4. My FlashDevelop intellisense recognizes all the lines above so I think it properly found the classes. However, it doesn't work on the device! Can anyone tell me how to fix this?
As usual, this problem which frustrated me for days had a very simple solution. To others who also ran into the same problem, remember to set Android's READ_PHONE_STATE permission to TRUE. And voila! It will work.