듀얼 SIM 모바일에서 두 SIM의 SIM 시리얼 번호/ID를 가져오고 싶습니다.Android : 듀얼 SIM 모바일에서 두 SIM의 SIM ID를 얻는 방법
4
A
답변
3
import java.lang.reflect.Method;
import android.content.Context;
import android.telephony.TelephonyManager;
public final class TelephonyInfo {
private static TelephonyInfo telephonyInfo;
private String imeiSIM1;
private String imeiSIM2;
private boolean isSIM1Ready;
private boolean isSIM2Ready;
public String getImeiSIM1() {
return imeiSIM1;
}
/*public static void setImeiSIM1(String imeiSIM1) {
TelephonyInfo.imeiSIM1 = imeiSIM1;
}*/
public String getImeiSIM2() {
return imeiSIM2;
}
/*public static void setImeiSIM2(String imeiSIM2) {
TelephonyInfo.imeiSIM2 = imeiSIM2;
}*/
public boolean isSIM1Ready() {
return isSIM1Ready;
}
/*public static void setSIM1Ready(boolean isSIM1Ready) {
TelephonyInfo.isSIM1Ready = isSIM1Ready;
}*/
public boolean isSIM2Ready() {
return isSIM2Ready;
}
/*public static void setSIM2Ready(boolean isSIM2Ready) {
TelephonyInfo.isSIM2Ready = isSIM2Ready;
}*/
public boolean isDualSIM() {
return imeiSIM2 != null;
}
private TelephonyInfo() {
}
public static TelephonyInfo getInstance(Context context){
if(telephonyInfo == null) {
telephonyInfo = new TelephonyInfo();
TelephonyManager telephonyManager = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));
telephonyInfo.imeiSIM1 = telephonyManager.getDeviceId();;
telephonyInfo.imeiSIM2 = null;
try {
telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceIdGemini", 0);
telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceIdGemini", 1);
} catch (GeminiMethodNotFoundException e) {
e.printStackTrace();
try {
telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceId", 0);
telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceId", 1);
} catch (GeminiMethodNotFoundException e1) {
//Call here for next manufacturer's predicted method name if you wish
e1.printStackTrace();
}
}
telephonyInfo.isSIM1Ready = telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY;
telephonyInfo.isSIM2Ready = false;
try {
telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimStateGemini", 0);
telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimStateGemini", 1);
} catch (GeminiMethodNotFoundException e) {
e.printStackTrace();
try {
telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimState", 0);
telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimState", 1);
} catch (GeminiMethodNotFoundException e1) {
//Call here for next manufacturer's predicted method name if you wish
e1.printStackTrace();
}
}
}
return telephonyInfo;
}
private static String getDeviceIdBySlot(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException {
String imei = null;
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try{
Class<?> telephonyClass = Class.forName(telephony.getClass().getName());
Class<?>[] parameter = new Class[1];
parameter[0] = int.class;
Method getSimID = telephonyClass.getMethod(predictedMethodName, parameter);
Object[] obParameter = new Object[1];
obParameter[0] = slotID;
Object ob_phone = getSimID.invoke(telephony, obParameter);
if(ob_phone != null){
imei = ob_phone.toString();
}
} catch (Exception e) {
e.printStackTrace();
throw new GeminiMethodNotFoundException(predictedMethodName);
}
return imei;
}
private static boolean getSIMStateBySlot(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException {
boolean isReady = false;
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try{
Class<?> telephonyClass = Class.forName(telephony.getClass().getName());
Class<?>[] parameter = new Class[1];
parameter[0] = int.class;
Method getSimStateGemini = telephonyClass.getMethod(predictedMethodName, parameter);
Object[] obParameter = new Object[1];
obParameter[0] = slotID;
Object ob_phone = getSimStateGemini.invoke(telephony, obParameter);
if(ob_phone != null){
int simState = Integer.parseInt(ob_phone.toString());
if(simState == TelephonyManager.SIM_STATE_READY){
isReady = true;
}
}
} catch (Exception e) {
e.printStackTrace();
throw new GeminiMethodNotFoundException(predictedMethodName);
}
return isReady;
}
private static class GeminiMethodNotFoundException extends Exception {
private static final long serialVersionUID = -996812356902545308L;
public GeminiMethodNotFoundException(String info) {
super(info);
}
}
}
private void isDualSimOrNot(){
TelephonyInfo telephonyInfo = TelephonyInfo.getInstance(this);
String imeiSIM1 = telephonyInfo.getImeiSIM1();
String imeiSIM2 = telephonyInfo.getImeiSIM2();
boolean isSIM1Ready = telephonyInfo.isSIM1Ready();
boolean isSIM2Ready = telephonyInfo.isSIM2Ready();
boolean isDualSIM = telephonyInfo.isDualSIM();
Log.i("Dual = "," IME1 : " + imeiSIM1 + "\n" +
" IME2 : " + imeiSIM2 + "\n" +
" IS DUAL SIM : " + isDualSIM + "\n" +
" IS SIM1 READY : " + isSIM1Ready + "\n" +
" IS SIM2 READY : " + isSIM2Ready + "\n");
}
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
+0
두 심의 IMEI를 반환합니다.하지만 SIM id가 필요합니다. – Salman
+0
그것은 모두 sim을 위해 일하고있다 –
+1
이것은 듀얼 SIM 폰과 소스가 하나 더있는 것은 작동하지 않을 것이다. http://stackoverflow.com/questions/14517338/android-check-whether-the-phone-is-dual- 시뮬레이션 –
관련 문제
- 1. 듀얼 SIM 모바일에서 현재/기본 SIM을 감지합니다.
- 2. Android 듀얼 SIM 카드 감지
- 3. 듀얼 SIM 카드 안드로이드
- 4. 듀얼 SIM 전화에서 IMEI를 읽는 방법
- 5. 듀얼 SIM 모바일에서 하나의 SIM에서 다른 SIM으로 SMS 보내기
- 6. 어떻게하면 듀얼 안드로이드 장치에서 두 심의 SIM ID를 얻을 수 있습니까? 내가 하나 개의 SIM의 ID를 얻고이 코드에 의해
- 7. 안드로이드 브로드 캐스트 리시버 및 듀얼 SIM
- 8. Dual-SIM 기본 SIM 카드 변경
- 9. 듀얼 폰의 특정 SIM 카드에서 SMS를 보내는 방법
- 10. 듀얼 SIM 체크 인터넷 연결 문제
- 11. 안드로이드는 듀얼 SIM 폰에서 슬레이브 시뮬레이션의 CellId와 LocationId를 캡쳐하지 않습니다.
- 12. sdk 레벨 미만의 듀얼 SIM 캐리어 이름을 식별하는 방법 android.os.Build.VERSION_CODES.LOLLIPOP_MR1
- 13. android sim 카드 리스너
- 14. dual sim android sdk
- 15. 듀얼 SIM Android 휴대 전화에서 작동하는 API가 있습니까?
- 16. 이중 SIM Android 장치에서 SMS를 보낼 때 SIM 카드를 선택하십시오.
- 17. Authorize.Net SIM 메소드를 사용하여 트랜잭션 ID를 얻는 방법
- 18. 듀얼 SIM에서 3g 서비스 용 SIM 카드를 선택하는 방법은 무엇입니까?
- 19. iOS/Android 앱에서 SIM 크레디트 사용 정책
- 20. 안드로이드 전화에서 sim의 계정 잔액을 얻는 방법
- 21. 슬레이브 슬롯에서 SIM의 운영자 이름을 얻는 방법?
- 22. SmsManager에 의해 듀얼 sim 안 드 로이드 전화에 sms 보내기
- 23. 이중 Sim 전화에서 Sim 번호 읽기 Xamarin.Form
- 24. sim 툴킷에 액세스하는 android 앱
- 25. Android ID로 Sim 연락처 삭제
- 26. SDK로 SIM PIN을 확인하십시오. Android
- 27. TelephonyManager를 사용하여 SIM 국가 코드 받기 - 방법?
- 28. 만들기 나는 지난 몇 일에서이 검색 한 듀얼 SIM 장치
- 29. 블랙 베리에서 장치 sim 번호의 ID를 얻으려면
- 30. SIM 카드가 바뀌었을 때의 이벤트
가능합니까? – Harshid