In my app i want to show the both inserted sim card mobile number to user in android studio . But i suffer from problem in which , i stuck at getting of second inserted sim mobile number . Help me to solve this.
Asked
Active
Viewed 4,474 times
-3
-
1look here: https://stackoverflow.com/questions/2480288/programmatically-obtain-the-phone-number-of-the-android-phone – Brokkoli 71 Apr 13 '20 at 12:31
-
2Does this answer your question? [Programmatically obtain the phone number of the Android phone](https://stackoverflow.com/questions/2480288/programmatically-obtain-the-phone-number-of-the-android-phone) – dawis11 Apr 13 '20 at 12:32
1 Answers
-1
TelephonyManager - "Provides access to information about the telephony services on the device. Applications can use the methods in this class to determine telephony services and states, as well as to access some types of subscriber information."
Code:
TelephonyManager telephonyManager =(TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
//SIM 1 Number
String mSimPhoneNumber1 = telephonyManager.getLine1Number();
//SIM 2 Number
String mSimPhoneNumber2 = telephonyManager.getLine2Number();
This method might returns a null on some phones.
Required Permission:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

Hayssam Soussi
- 903
- 7
- 16