2014-04-15 2 views
0

SmsManager 작업에 의해 sms를 보내고 싶습니다하지만 첫 번째 시뮬레이션에서 나는이 경우에 균형이 없다는 SMS 실패했습니다. 그래서 내 응용 프로그램에서만 두 번째 시뮬레이션으로 SMS를 보내는 방법. whatsApp와 같은 다른 앱은 내 두 번째 sim에서 reg 시간에 msg를 보낼 수 없습니다. 첫 번째 sim.so에서 가능한 균형을 사용할 수 없다고 생각합니다. PLS (사용자 정의 ROM과) Mlais MX28 전화의 로그를 분석 한 후 나에게SmsManager에 의해 듀얼 sim 안 드 로이드 전화에 sms 보내기

String mobileNo = phoneNumber1.getText().toString(); 

    try { 
    SmsManager smsManager = SmsManager.getDefault(); 
    smsManager.sendTextMessage(mobileNo, null, "BAL", null, null); 
    Toast.makeText(getApplicationContext(), "SMS Sent!", 
       Toast.LENGTH_LONG).show(); 
    } catch (Exception e) { 
    Toast.makeText(getApplicationContext(), 
     "SMS faild, please try again later!", 
     Toast.LENGTH_LONG).show(); 
    e.printStackTrace(); 
    } 
+0

볼 SIM2 http://stackoverflow.com/questions/5255147에 대한 SIM1 0과 1 인 경우/듀얼 심 카드 - 안드로이드 –

+0

@ shayanpourvatan 감사하지만 내 ans. 왜냐하면 whatsApp은 내 두 번째 시뮬레이션에서 reg 시간에 msg를 전송하기 때문에 가능한 것으로 생각합니다. pls help me – Ranu

+0

WhatsApp이 SMS를 보냈다고 생각하지 않습니다. SMS 만 수신합니다. – hitmaneidos

답변

0

도움, 나는 SMS를 보내기위한 SIM을 전환 할 수있는 다음과 같은 트릭을 발견했다. 안타깝게도 모든 앱에 대해 SIM을 전 세계로 전환하는 것으로 보입니다 (현재 지배적 인 설정을 '저장하고 복원'할 수있는 방법을 찾지 못했습니다). 또한 SIM 카드 각각에 할당 된 ID (sim_id)를 찾는 문제를 겪어야 할 것입니다 (아마도 휴대 전화의 로그 출력 확인을 통해 프로그래밍 방식으로이 작업을 수행 할 수 없습니다).

int simId = <place desired SIM ID here>; 
Intent simIntent = new Intent("android.intent.action.SMS_DEFAULT_SIM"); 
simIntent.putExtra("simid", simId); 
sendBroadcast(simIntent); 

이 코드가 사용자에게 적합 할 지 모르겠지만 (코드는 제조업체에 독립적으로 보이지만); 하지만 여전히 가치있는 일입니다.

는 업데이트 :

이상하게도, 이전의 접근 방식은 몇 가지 시도 후 작업을 정지했다. 그러나 좀 더 로그 분석을 한 후에 직접 설정 조작을 사용하는 다른 접근법을 발견하게되었습니다 (불행히도 android.permission.WRITE_SETTINGS 권한이 필요함). 내가 들여다

0

ContentValues val = new ContentValues(); 
val.put("value", "here goes the preferred SIM ID"); 
getContentResolver().update(Uri.parse("content://settings/system"), val, "name='sms_sim_setting'", null); 

나는 등 내 장치의 설정 데이터베이스가 gprs_connection_sim_setting 같은 설정 voice_call_sim_setting, video_call_sim_setting에 대한 항목이 포함대로,뿐만 아니라 다른 멀티 SIM-관련 작업에 대한 적응력이 생각 SubscriptionManager 클래스에서 getActiveSubscriptionInfoForSimSlotIndex (simIndex) 메서드를 찾아서이 subscriptionInfo를 사용하여 perticular sim 슬롯에 대한 subscriptionInfo를 얻었습니다. perticular simSlot의 subscriptionId를 얻을 수 있습니다. subscriptionID를 사용하여 우리는 이것은 나를 위해 일한

원하는 simSlot

에 대한 SMSManager를 얻을 수 있습니다 :

public void sendSMS(final String number,final String text){ 
    final PendingIntent localPendingIntent1 = 
    PendingIntent.getBroadcast(mContext, 0, new Intent(this.SENT), 0); 
    final PendingIntent localPendingIntent2 = 
    PendingIntent.getBroadcast(mContext, 0, new Intent(this.DELIVERED), 0); 

if (Build.VERSION.SDK_INT >= 22) 
{ 

    SubscriptionManager subscriptionManager=((Activity)mContext).getSystemService(SubscriptionManager.class); 
    SubscriptionInfo subscriptionInfo=subscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(simIndex); 
    SmsManager.getSmsManagerForSubscriptionId(subscriptionInfo.getSubscriptionId()).sendTextMessage(number, null, text, localPendingIntent1, localPendingIntent2); 
} 
SmsManager.getSmsManagerForSubscriptionId(subscriptionInfo.getSubscriptionId()).sendTextMessage(number, null, text, localPendingIntent1, localPendingIntent2); 
} 

을 simIndex이

관련 문제