Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Android
is there any other way to get sim number
shawn peter
Ranch Hand
Posts: 1325
1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I need to get the sim number programtically in android.I used below
telephonyManager.getLine1Number(); but it always get get null values.
is there any other ways to get sim no?
sonu raj
Ranch Hand
Posts: 43
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
Mobile number is only available if your device is able to get it otherwise this method will return null. There is another way to get phone number if 'whatspp' is installed on the device
import java.util.ArrayList; import android.accounts.Account; import android.accounts.AccountManager; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class Check extends Activity { TextView checkn; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.check); checkn=(TextView)findViewById(R.id.CWPN); AccountManager am = AccountManager.get(this); Account[] accounts = am.getAccounts(); String acname=null; String actype=null; ArrayList<String> googleAccounts = new ArrayList<String>(); for (Account ac : accounts) { acname = ac.name; actype = ac.type; // Take your time to look at all available accounts System.out.println("Accounts : " + acname + ", " + actype); } //Check actype for whatsapp account if(actype.equals("com.whatsapp")){ String phoneNumber = acname; checkn.setText(phoneNumber); } } }
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to get radio button value
about request.getAttribute
how to get back bean value in javascript
How to handl Null Values from Database
how to get the value from the readonly field?????
More...