1

I want to know is it possible to get a user phone number of device where app is running or not? I am using 4.6 version.

If yes, please notice me how / which extensions/libraries i should use.

Thank you for your time xsiraul

xsiraul
  • 414
  • 1
  • 5
  • 16

1 Answers1

1

EDIT:

In re-reviewing this question, it seems you are specifically asking about AIR and access to a telephone number via Android. I'm making that assumption based on the "android" tag but please edit your question to be specific since building an App on AIR for mobile devices could target multiple platforms.

For AIR development on an Android platform, I don't believe there is access directly to the "TelephonyManager" via the Actionscript API.

Normally, in Java building to Android, you would do something similar to this:

TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String myNumber = mTelephonyMgr.getLine1Number();

However, since you're on AIR, you'll need to either find or build a "Custom Extension" to add to the AIR SDK. Here is a tutorial on how to do so (from this SO answer): http://www.jamesward.com/2011/05/11/extending-air-for-android/

Someone has tried to create a custom AIR extension for accessing the TelephonyManager but it seems they weren't successful in finishing the Extension. It should be very straightforward to build a simple extension to access the manager and the information you want (assuming this is for an Android device). However, you'll need to program defensively, because not all phone numbers are stored on the device SIM card.

I hope this helps, and my apologies at assuming this was for an iOS environment.

Community
  • 1
  • 1
Dominic Tancredi
  • 41,134
  • 7
  • 34
  • 50
  • Thank you, but NSUserDefaults is not used in Adobe Flex. But still, your answer is useful for me, I learnt some new stuff. – xsiraul Jul 15 '12 at 18:35
  • In the original api, I don't believe it is. However, if you wanted to compile a "custom native extension" (obj-c to actionscript) bridge, theoretically you could do so. Here's a tutorial how: http://custardbelly.com/blog/2011/09/21/air-native-extension-example-ibattery-for-ios/ – Dominic Tancredi Jul 15 '12 at 18:44
  • -1 for not reading. The original question makes no mention of iOS and is explicitly tagged as Android. Why would the iOS Terms and Conditions apply here? – JeffryHouser Jul 15 '12 at 18:48
  • 1
    Thanks for pointing that out! I edited the question to specifically respond to "Android". Long day, not sure why I missed that. – Dominic Tancredi Jul 16 '12 at 01:41