TelephonyManager.getLine1Number() returning null?

by David Given » Wed, 28 Apr 2010 21:28:29 GMT


Sponsored Links
 -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to fetch the telephone number of the device. I'm calling
TelephonyManager.getLine1Number(), and it's returning null.

A trawl of the intertubes shows that there's a potential problem with
some SIMs not containing this information; however, Settings->About
Phone->Status *does* show the correct phone number, so this isn't it.

Looking at the code, it appears that Settings isn't using
TelephonyManager to retrieve the phone number. Instead it's using
com.android.internal.telephony.Phone, an internal API, to do this; so
obviously this is working, where TelephonyManager is not.

Can anyone shed any light on this, and hopefully suggest how I can
correctly fetch the phone number?

- -- 
€€  €€€€€  http://www.cowlark.com  €€€€€
life  .^3 4=+/,1 0 1 0 1}
--- Conway's Game Of Life, in one line of APL
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -  http://enigmail.mozdev.org/ 

iEYEARECAAYFAkvYN9wACgkQf9E0noFvlzg6WwCgmyZDbGV1IqqnIUTUBxjtgmUZ
YL8An2mrVxtNy+i8kjeFniytTIY8UYvP
=6p5u
-----END PGP SIGNATURE-----

--



TelephonyManager.getLine1Number() returning null?

by David Given » Wed, 05 May 2010 18:53:49 GMT


 -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



[...]

Does anyone know anything about this?

- -- 
€€  €€€€€  http://www.cowlark.com  €€€€€
life  .^3 4=+/,1 0 1 0 1}
--- Conway's Game Of Life, in one line of APL
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla -  http://enigmail.mozdev.org/ 

iEYEARECAAYFAkvhTh0ACgkQf9E0noFvlzjo4ACfTvvkmZS+bx4qbSGdhFXe/Odw
UAcAoL/HYT59nnVL86s6sNymD6wlklEs
=MTvd
-----END PGP SIGNATURE-----

--


Sponsored Links


TelephonyManager.getLine1Number() returning null?

by Vinay S » Wed, 05 May 2010 19:32:34 GMT


 Hi David,

I think you are trying to use TelephonyManager.getLine1Number();

Instead create an object of the TelephonyManager and then call the
getLine1Number();

-Vinay




>



TelephonyManager.getLine1Number() returning null?

by Mark Ellul » Wed, 05 May 2010 19:48:57 GMT


 I was informed that its a SIM issue, and that some SIM cards do not
store the telephone number in the appropriate way to retrieve the
number





> >



TelephonyManager.getLine1Number() returning null?

by Vinay S » Thu, 06 May 2010 13:41:23 GMT


 Hi David,

Pl. try this code..

TelephonyManager tMgr = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE) ;
Log.d(""+tMgr.getLine1Number() ) ;

-Vinay





>



TelephonyManager.getLine1Number() returning null?

by Vinay S » Thu, 06 May 2010 13:48:25 GMT


 Hi,

Are you sure, you are getting the context correctly..?
Are you able to get other deatils, like Network type phone type, sim
status etc?

-Vinay





>



Other Threads

1. Searching in a tab

I have a tab host with two tabs.  I want one of those tabs to be a
search screen.  The content for the tab is a ListActivity.  I'm
pulling the content from a web service.

My problem is, when I execute the search a new intent is pushed onto
the screen.  I've used the android:launchMode="singleTop" property in
my manifest for the search activity.  What that seems to have done is,
once the new intent is pushed on top of the TabActivity, every time I
run the search it reuses that intent.  But I want the already existing
intent which is set as the tab's content to be the one it uses.

What can I do?

-- 

2. Emulator 2.1 & 2.2 reverse geocoding not available

im running into the same issue with Geocoder in Android 2.2 level 8 as
well. any update on this? please let me know. thanks!




-- 

3. Custom ContentProvider in shared libarary - bad design?

4. Htc Legend as developer?

5. Installing adobe air runtime timeout ??

6. res/drawable/ not in Eclipse ?

7. OnTouchListener does not receive all MotionEvents in MapActivity