dtvq4978 2014-05-22 11:13
浏览 35
已采纳

在数据库服务器中存储UDID - Android

I have generated a UDID string on the client side of Android. I need to send this to the javascript side so that it could communicate to the database server (via php) in order to store this UDID.

Is there a way to do it either directly (by avoiding php) or otherwise?

** My Android application has a WebView

  • 写回答

2条回答 默认 最新

  • douyan1244 2014-05-22 11:22
    关注

    Post to http with params:

    public void postData() {
        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://www.yoursite.com/yourexample.php");
    
    
    
    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("UDID", "12345"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
    
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block
    }
    }
    

    for your server side maybe it would be useful to learn somethings about web api's. take a look at this 2 links to start from some place:
    Creating a RESTful API with PHP
    [GUIDE] Android Client-Server Communication (PHP-MYSQL REST API)

    You should show what you have already done, take a look at this to make better - to the point- questions

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?