I want to get the SIM's phone number .
My Manifest file is..
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ambre.bazarmada"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.SEND_SMS" />
....
</application>
</manifest>
and my code in acivity to get Phone number is as ..
public static String getPhoneNumber(Context ctxt) {
TelephonyManager phoneManager = (TelephonyManager) ctxt.getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = phoneManager.getLine1Number();
return phoneNumber;
}
The phone is Samsung Galaxy S2 , the problem is that the function getPhoneNumber returns null. So what is wrong in my code?