I want to g开发者_开发问答et device phone number through JavaScript for validating user.
I am sending sms to client when he clicks on a URL I need to perform some operation.
For that, I want to get device phone number on smartphones.
If your javascript is part of a webpage and is displayed in Android browser than you are out of luck. It behaves the same way as javascript on other browsers - it can't access any underlying operating system functions.
On the other hand if your javascript is part of installable Android application (and executed in WebView) then javascript can call your custom Java function which provides this info. Of course your application will have to request the privilege to access personal info at install time and user will have to confirm this.
Ask them to enter in into a form - otherwise Ankit is right, it's a security / privacy issue. They might not want you to know their number.
精彩评论