【发布时间】:2015-05-23 17:58:34
【问题描述】:
我正在开发一个应用程序,当您之前收到一条短信时,它会向网站发送短信。我的问题是,当我尝试从以前收到的 SMS 中发送几条 SMS...一。有人能帮我吗?谢谢:)
public class GetSMSTask extends AsyncTask<Void, Void, Void> {
private Context mContext;
public GetSMSTask(Context context) {
mContext = context;
}
private static final String SMSBROKER = "http://xx.xx.xx.xx:8080/smsbroker/{params}";
@Override
protected Void doInBackground(Void... arg0) {
OutcomeSms os=new OutcomeSms();
String texto = null;
String msisdn = null;
HashMap<String, List<String>> hash = new HashMap<String, List<String>>();
List<String> list = new ArrayList<String>();
try {
org.apache.http.client.HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(SMSBROKER);
HttpResponse response = client.execute(get);
Log.w("PlaySMSBroker","postSingal Response: " + response.getStatusLine());
os.sendSMSMessage(msisdn, texto, mContext);
list.add(texto);
hash.put(msisdn,list);
List<String> listOfMessages = hash.get(msisdn);
int numberOfMessages = listOfMessages.size();
for (int i=1; i<numberOfMessages; i++){
os.sendSMSMessage(msisdn, texto, mContext);
}
} catch (UnsupportedEncodingException e) {
Log.e("PlaySMSBroker", "UnsupportedEncodingException:" + e.getMessage());
} catch (ClientProtocolException e) {
Log.e("PlaySMSBroker", "ClientProtocolException:" + e.getMessage());
} catch (IOException e) {
Log.e("PlaySMSBroker", "IOException:" + e.getMessage());
} catch (Exception e) {
Log.e("PlaySMSBroker", "Exception" + e.getClass().toString());
}
return null;
}
}
【问题讨论】: