
我的手机中有一个android应用程序,在其中填充了一些数据,然后将这些数据附加到数据库中.所以我打算在我的应用程序中添加一个按钮(sms按钮),按此按钮时,数据必须更新到服务器数据库,或者可以将数据转储到服务器中.所以我想知道我们可以将短信发送到服务器吗?如果是的话,如何?
注意:我有一台具有静态IP地址的服务器.
解决方法:
尝试将数据发布到服务器.
public voID postData() { // Create a new httpClIEnt and Post header httpClIEnt httpclIEnt = new DefaulthttpClIEnt(); httpPost httppost = new httpPost("http://www.yoursite.com/script.PHP"); try { // Add your data List<nameValuePair> nameValuePairs = new ArrayList<nameValuePair>(2); nameValuePairs.add(new BasicnameValuePair("ID", "msgid")); nameValuePairs.add(new BasicnameValuePair("stringdata", "Msg u want send")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute http Post Request httpResponse response = httpclIEnt.execute(httppost); Log.v("myapp", "response " + response.getEntity()); String responseBody = EntityUtils.toString(response.getEntity()); } catch (ClIEntProtocolException e) { // Todo auto-generated catch block } catch (IOException e) { // Todo auto-generated catch block }} 可以参考Android HttpPost: how to get the result
http://www.anddev.org/doing_http_post_with_android-t492.html
以上是内存溢出为你收集整理的有没有办法将短信从Android手机发送到服务器?全部内容,希望文章能够帮你解决有没有办法将短信从Android手机发送到服务器?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)