Are there alternate ways to look up user phone number when TelephonyManager returns null?

by Muthu Ramadoss » Fri, 10 Apr 2009 16:15:15 GMT


Sponsored Links
 Is there a way to look up the user phone number other than TelephonyManager?

In my G1, this returns null:

// get your phone number
        TelephonyManager telephonyManager = (TelephonyManager)
                getSystemService(Context.TELEPHONY_SERVICE);
        String tel = telephonyManager.getLine1Number();

        Log.i("Telephone Number ==> ", tel+" <==");


Is there any other way of getting user's own phone number?

take care,
Muthu Ramadoss.

 http://linkedin.com/in/tellibitz 
 http://androidrocks.googlecode.com  - Android Consulting.

Emo Philips < http://www.brainyquote.com/quotes/authors/e/emo_philips.html> ;
- "A computer once beat me at chess, but it was no match for me at
kick
boxing."

--~--~---------~--~----~------------~-------~--~----~



Are there alternate ways to look up user phone number when TelephonyManager returns null?

by Mark Murphy » Fri, 10 Apr 2009 19:56:17 GMT


 


Not only does this apparently return null in some cases (like you got),
it does not have to necessarily return a valid value.

I tried your code, and I get a phone number that I *think* is what I was
originally assigned when I bought the G1, before my other T-Mobile
number could be ported over.

So I am not certain this method is reliable in any case.


Hopefully yes, though I don't know of one...

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books.html 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Are there alternate ways to look up user phone number when TelephonyManager returns null?

by strazzere » Fri, 10 Apr 2009 23:08:09 GMT


 Does your G1 display the correct line number through settings?
(Settings > About phone > Status > Phone Number)

This method used by the system seems to always be accurate, but I
believe it is a private API;

// Snippit from
 http://android.git.kernel.org/?p=platform/packages/apps/Settings.git ;a=blob_plain;f=src/com/android/settings/deviceinfo/Status.java;hb=HEAD

import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;

...

Phone mPhone = PhoneFactory.getDefaultPhone();

...

setSummaryText("number", mPhone.getLine1Number());

// End snippit







--~--~---------~--~----~------------~-------~--~----~



Are there alternate ways to look up user phone number when TelephonyManager returns null?

by Muthu Ramadoss » Fri, 10 Apr 2009 23:22:22 GMT


 My G1 says "Unknown" when (Settings > About phone > Status > Phone
Number)

I haven't tried your new code snippet. I'll report back with the
results. Thanks.





--~--~---------~--~----~------------~-------~--~----~



Are there alternate ways to look up user phone number when TelephonyManager returns null?

by strazzere » Sat, 11 Apr 2009 00:45:43 GMT


 What type of phone are you using? Does it have a simcard and/or work
on your carrier network?

If the About phone/Status is not showing, then I doubt the snippit
would work even if you could compile it (your not going to be able to
using the standard SDK)






--~--~---------~--~----~------------~-------~--~----~



Are there alternate ways to look up user phone number when TelephonyManager returns null?

by Muthu Ramadoss » Sat, 11 Apr 2009 14:24:14 GMT


 I have an ADP1 bought from market that I use with a local GSM carrier
in Chennai. The phone works perfectly, although we use only GPRS and
not 3G.

But the phone number is always displayed as "Unknown".








--~--~---------~--~----~------------~-------~--~----~



Are there alternate ways to look up user phone number when TelephonyManager returns null?

by Edward Falk » Sun, 12 Apr 2009 00:47:16 GMT


 I encountered the same issue with a new Sim card I bought from the T-
Mobile store.  In a couple weeks, it started returning the correct
phone number, but it initially returned null.  I modified my software
to allow the user to enter the phone number if I couldn't find it from
the telephony manager.
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Overriding the home button

Hello,

I am trying to override the home button in my application. I am aware
that this is not recommended behaviour and all links I've found about
this says that it is actually not possible. However, the native dialer
of HTC Sense as well as the dialer for Sony Ericsson (tested on X10
mini) both ignore the home button press on incomming calls. How can I
do the samein my app?

/Schoel

-- 

2. How to change the highlight text color in the edittext, not the background color

hi,
       There is a requirement to change the selected text color of edittext,
 I found t  text color, highlight color(the background color of the selected
color) and a hint color, but no selected text color.

 How to change the highlight text color in the edittext. Thank you!

-- 

3. Facebook connect for android

4. Android and XMLHttpRequest()

5. enable V8 snapshot is easy to crash by SIGILL

6. OMA DRM forward lock

7. CANNOT LINK EXECUTABLE