We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi experts, I am new to Processing and I enjoy this very much already. Some solutions are shown here: http://stackoverflow.com/questions/18894080/get-my-phone-number-in-android I wonder if there is any library function available in Processing to get the telephone number.
Thanks in advance.
AR
Answers
I meant in the device = Android phone. Apologies for not being clear first.
@ARM===
p5 does not need a lib for that! - the TelephonyManager class + getLine1Number() from android can be used for that, though it is not reliable (because a phone does not need to "know" this number: it receives the call from the network!) - Yet, as for me, i strongly disagree with an app which gets my phone number and phone numbers from all users who install it on their phones...Then, why not, makes some kind of database which can be send anywhere and to anybody. So, if really you have to get this number make a dialog and ask it from the user himself!
akenaton, Thank you very much. I love Processing and its team!
If there is an example code somewhere please let me know.
Yes, absolutely. User decides what she/he wants to share. I need to generate unique ID for each person and I need to reach them back at a later stage, so will be prompting them on how to reach them email or their phone number (via text message). They can accept/reject at that stage.
akenaton,
I am trying to get sample Processing code for the TelephonyManager class + getLine1Number() and unable to find one. Can you please give me some link, if there is an example code somewhere. Advance Thanks. If the code is available as a direct Java code for Android (not a processing code), how can I club that and Processing, please. Thanks.
@ARM===
have a look here::
https://developer.android.com/reference/android/telephony/TelephonyManager.html
you have to import the telephonyManager class && the Activity class
then use this code (changing according to the fragment context)
TelephonyManager telMan = (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE); String phoneNumber= telMan.getLine1Number();
probably also you have to add permission (readphonestate) in your manifest, not sure about that.