2015-05-17 58 views
0

对不起,如果这个问题已经被问到或似乎很愚蠢,但我卡住了。我正在编写一个Android应用程序,在该应用程序中,应用程序向不同的人发送不同的消息,第一个成功发送,但第二个发生了问题,它不会向我显示错误,但它不会发送第二个消息。我的代码如何从Android应用程序发送多条短信?

public void sendSMSMessenger(){ 
    Log.i("Send SMS", ""); 



    try { 
      // SmsManager smsManager = SmsManager.getDefault(); 
      SmsManager.getDefault().sendTextMessage(Emergencyphonenumber, null, "There is an emergency with your "+PatientRelationship+" "+Patientname+" please open the link to find the location "+"https://www.google.com/maps/place/"+latitude+","+longitude, null, null); 
      Toast.makeText(this, "Message Sent (Relative)", Toast.LENGTH_SHORT).show(); 
      SmsManager.getDefault().sendTextMessage(Doctorphonenumber, null, "There is an emergency with your patient named "+Patientname+" please open the link to find the location "+"https://www.google.com/maps/place/"+latitude+","+longitude, null, null); 
      Toast.makeText(this, "Message Sent (Doctor)", Toast.LENGTH_SHORT).show(); 





      } catch (Exception e) { 
       Toast.makeText(this, "Message Sending failed", Toast.LENGTH_SHORT).show(); 
      e.printStackTrace(); 
      } 

} 

谢谢....

+0

这是因为当您试图一个接一个地发送消息时,网络被卡住了。所以解决方法是,等待15-30秒后尝试发送下一条消息。希望你明白。 – Lal

+1

@Lal,你能否澄清一下你的意思是“__ network is jammed__”? –

回答

0

不能同时发送消息。在某种程度上,网络难以共同处理所有消息。等一下。增加时间。

相关问题