2013-11-01 50 views
2

我創建了短信應用android 我已經能夠順利地發送短信,但通過SIM卡發送1如果我發送2 SIM卡應用程序,它會出錯,並且沒有報告發送如果我想要做短信2發送SIM順利 請幫助我應該怎麼加其如何使用SIM2或雙SIM卡提交短信

我的代碼

public class MainActivity extends Activity { 

    Button sendBtn; 
    EditText txtphoneNo; 
    EditText txtMessage; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     sendBtn = (Button) findViewById(R.id.btnSendSMS); 
     txtphoneNo = (EditText) findViewById(R.id.editTextPhoneNo); 
     txtMessage = (EditText) findViewById(R.id.editTextSMS); 

     sendBtn.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      sendSMSMessage(); 
     } 
     }); 

    } 
    protected void sendSMSMessage() { 
     Log.i("Send SMS", ""); 

     String phoneNo = txtphoneNo.getText().toString(); 
     String message = txtMessage.getText().toString(); 

     try { 
     SmsManager smsManager = SmsManager.getDefault(); 
     smsManager.sendTextMessage(phoneNo, null, message, null, null); 
     Toast.makeText(getApplicationContext(), "SMS sent.", 
     Toast.LENGTH_LONG).show(); 
     } catch (Exception e) { 
     Toast.makeText(getApplicationContext(), 
     "SMS faild, please try again.", 
     Toast.LENGTH_LONG).show(); 
     e.printStackTrace(); 
     } 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

} 

回答

1

Android SDK提供有雙SIM卡的設備不支持的源代碼。您需要聯繫設備製造商以確定是否以及如何使用第二張SIM卡發送短信。

+0

Android SDK 5.1及更高版本中可用的模擬選擇選項 – harikrishnan

相關問題