Re: [android-developers] Re: TelephonyManager.getLine1Number() returning null?

2010-05-06 Thread Second Dancer
You can get an reflection call on the internal Api

On May 6, 2010 5:48 AM, Vinay S s.vinay@gmail.com wrote:

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


On May 5, 9:32 pm, David Given d...@cowlark.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Has...
  I think you are trying to useTelephonyManager.getLine1Number();

  Instead create an object of theTelephonyManagerand then call the

  getLine1Number();

 We're already doing that --- here's the code:

TelephonyManagertm = (TelephonyManager)

 _context.getSystemService(Context.TELEPHONY_SERVICE);
 return despace(tm.getLine1Numb...
 For more options, visit this group athttp://
groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers ...

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: TelephonyManager.getLine1Number() returning null?

2010-05-05 Thread Vinay S
Hi David,

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

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

-Vinay

On May 5, 3:53 pm, David Given d...@cowlark.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 28/04/10 14:27, David Given wrote:
 [...]

  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?

 Does anyone know anything about this?

 - --
 ┌─── dg@cowlark.com ─http://www.cowlark.com─
 │
 │ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯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-

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: TelephonyManager.getLine1Number() returning null?

2010-05-05 Thread Mark Ellul
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

On May 5, 1:32 pm, Vinay S s.vinay@gmail.com wrote:
 Hi David,

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

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

 -Vinay

 On May 5, 3:53 pm, David Given d...@cowlark.com wrote:





  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1

  On 28/04/10 14:27, David Given wrote:
  [...]

   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?

  Does anyone know anything about this?

  - --
  ┌─── dg@cowlark.com ─http://www.cowlark.com─
  │
  │ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯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-

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group 
  athttp://groups.google.com/group/android-developers?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: TelephonyManager.getLine1Number() returning null?

2010-05-05 Thread David Given
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/05/10 12:48, Mark Ellul wrote:
 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

That's what I originally thought, but as I said, Settings-About Phone
*is* returning the correct phone number. Something on the phone must be
able to determine it.

 On May 5, 1:32 pm, Vinay S s.vinay@gmail.com wrote:
 Hi David,

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

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

We're already doing that --- here's the code:

TelephonyManager tm = (TelephonyManager)
_context.getSystemService(Context.TELEPHONY_SERVICE);
return despace(tm.getLine1Number());

(_context is our activity, despace() is a function that removes spaces
from a string.)

As I said in my original message, the code *works*. It just always
returns null. So it's not a compilation problem.

- -- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯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/

iEYEARECAAYFAkvhnagACgkQf9E0noFvlzg47ACeK9J4jSzgraXTWAAtD+M7BjEi
2zgAoLlHl3NRP1MdLFdCCrDtQeE9i6dh
=pS74
-END PGP SIGNATURE-

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: TelephonyManager.getLine1Number() returning null?

2010-05-05 Thread Vinay S
Hi David,

Pl. try this code..

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

-Vinay

On May 5, 9:32 pm, David Given d...@cowlark.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 05/05/10 12:48, Mark Ellul wrote:

  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

 That's what I originally thought, but as I said, Settings-About Phone
 *is* returning the correct phone number. Something on the phone must be
 able to determine it.

  On May 5, 1:32 pm, Vinay S s.vinay@gmail.com wrote:
  Hi David,

  I think you are trying to useTelephonyManager.getLine1Number();

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

 We're already doing that --- here's the code:

    TelephonyManagertm = (TelephonyManager)
         _context.getSystemService(Context.TELEPHONY_SERVICE);
     return despace(tm.getLine1Number());

 (_context is our activity, despace() is a function that removes spaces
 from a string.)

 As I said in my original message, the code *works*. It just always
 returns null. So it's not a compilation problem.

 - --
 ┌─── dg@cowlark.com ─http://www.cowlark.com─
 │
 │ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯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/

 iEYEARECAAYFAkvhnagACgkQf9E0noFvlzg47ACeK9J4jSzgraXTWAAtD+M7BjEi
 2zgAoLlHl3NRP1MdLFdCCrDtQeE9i6dh
 =pS74
 -END PGP SIGNATURE-

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: TelephonyManager.getLine1Number() returning null?

2010-05-05 Thread Vinay S
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

On May 5, 9:32 pm, David Given d...@cowlark.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 05/05/10 12:48, Mark Ellul wrote:

  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

 That's what I originally thought, but as I said, Settings-About Phone
 *is* returning the correct phone number. Something on the phone must be
 able to determine it.

  On May 5, 1:32 pm, Vinay S s.vinay@gmail.com wrote:
  Hi David,

  I think you are trying to useTelephonyManager.getLine1Number();

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

 We're already doing that --- here's the code:

    TelephonyManagertm = (TelephonyManager)
         _context.getSystemService(Context.TELEPHONY_SERVICE);
     return despace(tm.getLine1Number());

 (_context is our activity, despace() is a function that removes spaces
 from a string.)

 As I said in my original message, the code *works*. It just always
 returns null. So it's not a compilation problem.

 - --
 ┌─── dg@cowlark.com ─http://www.cowlark.com─
 │
 │ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯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/

 iEYEARECAAYFAkvhnagACgkQf9E0noFvlzg47ACeK9J4jSzgraXTWAAtD+M7BjEi
 2zgAoLlHl3NRP1MdLFdCCrDtQeE9i6dh
 =pS74
 -END PGP SIGNATURE-

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en