How to obtain Phone Number in Android? - android

This is an extension to the question here. Now I quote CommonsWare
There is no reliable way to retrieve mobile number of device programatically. The only option remaining and I can think of is getting user to input for the phone number.
My question is how to check if the phone number entered by the user is correct for these and any more possibilities which I cannot think now:
The number entered by the user is of the same device the app has been downloaded on.
User did not make any typographical error while entering the number
User did not enter any local calling code like leading 0
I have spend sufficient time on StackOverflow and web and this is not a duplicate question.
I will appreciate any help, clues or suggestions.

1.The number entered by the user is of the same device the app has been downloaded on.
Again this is something kind of impossible to test, else the Tricky way mentioned by #neteinstein
2.User did not make any typographical error while entering the number
3.User did not enter any local calling code like leading 0
I think you still not aware of this library by google,used for Parsing/formatting/validating phone numbers for all countries/regions of the world.
Using that you can achive your other 2 solutions.I think.
Link : http://code.google.com/p/libphonenumber/

If you are willing to possibly spend some user money you can send an SMS to yourself (number inputted by the user) and check if it arrives.
If it does, the number is correct. If not... either you have no network, or the number is incorrect.
I don't even think the phone has the number visibility, according to my experience with Mobile Operators, only on their side they have that visibility.

Though I do not know about nr1, I think you can solve problem nr 2 and 3 quite easily by analysing the number while its a String. That way you can easily check what characters it contains and what positions these characters are on.
I hope this helps.
Greets,
Wottah

Related

Im in absolute must recover text msgs in my storage

Im not sure if im in the right place to ask this of you experts. I am not a computer person and very unaware of the dynamics of them..im in absolute desperate need to retrieve all text msgs from one number beginning 7.23.18. Ive tried to do everything i possibly could do and might have fsctory reset all info. But i did find some thing in .../storage/emulated/0/android/data/com.google.android.apps.messaging......and..../files... Is this some of them....i dont know and if they are part....i have no idea how to retrieve them to be readable...i keep trying..for weeks...if one of you experts can share your intellectual knowledge...i will even pay for it to get all these...i have to have them...im being stalked and this is is only way i can put him away for life.....before he comes back....thank you more than you know....just fir giving me your time to read my request...i guess ill just wait to see what happens...Debbie. Ventura Beach, Ca. 🌊 📲🔫
Reach out to your wireless provider.
T-Mobile has all my texts going back years.

Obtaining Telephone Number from a Call at a Specific Moment in Time

New to Android development and I’d like to very quickly check if the user is in a call AND get the phone number of the person the user is in a call with. In reviewing https://developer.android.com/reference/android/telephony/package-summary, it appears quickly grabbing this phone number is not possible. It appears the only time the number is available is with a PhoneStateListener and onCallStateChanged during an actual “state change” or using a BroadcastReceiver with state changes and grabbing EXTRA_INCOMING_NUMBER or related when a change occurs. Am I missing anything?
Thank you.
you're not missing anything, that's the way to do it.

Want to programmatically access user-entered Android Device Name

The Android SDK class Build.VERSION gives programmatic access to many (relatively) hard-wired values from the phone, as has been discussed in several other threads. But I am looking for a way to access the "Device name" value the user can enter/change from the About Phone dialog.
When I first went to About Phone on my Galaxy S4, the "Device name" value was SCH-1545, which is the same value as I get if I print out
android.os.Build.MODEL
The phone lets me enter a new value, say, "Foo bar" but, as I rather expected, that did not change the value of android.os.Build.MODEL, even after rebooting the phone. Nor did it change the value of
android.os.Build.USER
which seemed the only other field it might affect.
Is there a way to access the value that the user can change/see?
Actually, it turns out that this question is essentially a duplicate of another question which I was unable to find with my original search terms and I have since up-voted. The short answer is: yes, for some phones but not in the general case, AND you have to request bluetooth permission to use the call that can do it. IOW, ugh, no not really.
I'm leaving this question up in the hope that the terminology I use may help another searcher find the answer more quickly.
That is most probably the device name from Bluetooth.
Use BluetoothAdapter to access the name.

How to move SMS to secure box in HTC

I'm making an Android program. It's SMS related. I have an HTC and since UI has secure box option to move SMS, I want to "move" to this folder in my program. Does anyone know how to do that? And of course validate if this feature exists before trying to move?
I figure it out. You need to update the SMS database and update the htc_category column to 1.
Just use contentResolver and uri content//sms/ (like update read sms) and just update that column too.
on the htc go to msg then on the top your going to see messages pass secure

android how to get the emergency number to call

I see there are plenty of examples on how to call a number, and I also see that I can only have it pop up the dialer to go to an emergency number. But in all those example they hard coded "911" as the number to use. well this works fine in the US but since android phones are sold in other countries and thusly there is the possibility that my app will be bought by someone not in the US, or that someone who lives in the us may take their phone overseas; is there a way then my app can realize it's not in the us and thusly has to use a different number to call emergency service and what that number would be?
So to sum up I'd like to know if there is a way I can have it so when the app goes to bring up the dialer with the emergency number for the country it's in, with out having to know that number at complie time?
According to the source for PhoneNumberUtils.isEmergencyNumber():
String numbers = SystemProperties.get("ril.ecclist");
if (TextUtils.isEmpty(numbers)) {
// then read-only ecclist property since old RIL only uses this
numbers = SystemProperties.get("ro.ril.ecclist");
}
numbers will be a comma separated list.

Categories

Resources