Android examples for Phone:Sim
get Phone SIM By Slot
//package com.java2s; import android.content.Context; import android.telephony.TelephonyManager; import java.lang.reflect.Method; public class Main { public static String getPhoneBySlot(Context context, int slotID) { String phone = ""; if (context == null) { return ""; }//from ww w . j a v a2s .c o m if (slotID < 0 || slotID > 1) { return ""; } try { TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); Class<?> mLoadClass = Class .forName("android.telephony.TelephonyManager"); Class<?>[] parameter = new Class[1]; parameter[0] = int.class; Method getLine1NumberGemini = mLoadClass.getMethod( "getLine1NumberGemini", parameter); Object[] obParameter = new Object[1]; obParameter[0] = slotID; Object ob_phone = getLine1NumberGemini.invoke(telephonyManager, obParameter); if (ob_phone != null) { phone = ob_phone.toString(); } } catch (Exception e) { } return phone; } }