How can I get the ICCID number of my phone?
I believe I will get iccid. getSimSerialNumber()
For Android 5.1+, see this answer to this question for which I deserve zero points.
source to share
UPDATE for Android 5.1 (Credit to Erick M Sprengel )
Added "Multiple SIM support" for Android 5.1 (API 22). Instead of using, getSimSerialNumber
you can use . SubscriptionManager
SubscriptionManager sm = SubscriptionManager.from(mContext);
// it returns a list with a SubscriptionInfo instance for each simcard
// there is other methods to retrieve SubscriptionInfos (see [2])
List<SubscriptionInfo> sis = sm.getActiveSubscriptionInfoList();
// getting first SubscriptionInfo
SubscriptionInfo si = sis.get(0);
// getting iccId
String iccId = si.getIccId();
You will need a permit: ( Damian's loan )
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
source to share
@Jakar, thanks a lot! Here's the same code in C # using Xamarin / Mono.Android
Requires permission set in your AndroidManifest.xml
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Simple C #
using System.Collections.Generic;
using Android.Telephony;
// ...
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Requires, android.permission.READ_PHONE_STATE
SubscriptionManager sm = Android.Telephony.SubscriptionManager.From(Android.App.Application.Context);
IList<SubscriptionInfo> sis = sm.ActiveSubscriptionInfoList;
SubscriptionInfo si = sis[0];
string carrier = si.CarrierName;
string iccId = si.IccId;
string phoneNum = si.Number;
System.Diagnostics.Debug.WriteLine("Carrier: " + carrier);
System.Diagnostics.Debug.WriteLine("SIM Card IccId: " + iccId);
System.Diagnostics.Debug.WriteLine("Phone Number: " + phoneNum);
// Bonus, Get the IMEI Id (aka, DeviceId)
TelephonyManager tm = (TelephonyManager)GetSystemService(Android.Content.Context.TelephonyService);
string deviceId = tm.DeviceId;
System.Diagnostics.Debug.WriteLine("Device Id: " + deviceId);
}
Both SubscriptionManager and SubscriptionInfo are in the Android.Telephony namespace
In truth, this example was needed to activate my phone on the fly and without the ability to use the SIM card tool. And my eyes are not what they use. Have a look at DroidTelephonySimInfo.cs at gist.github.com
source to share