how to send data from android to server

后端 未结 1 521
面向向阳花
面向向阳花 2020-12-18 11:51

I\'m exploring to scan ssid and rssi from android and I\'m able to do it, but now i have want send the data to the server, so i explore i found below code

          


        
相关标签:
1条回答
  • 2020-12-18 12:35

    I would recommend you to switch to JSON for sending data to the server. Google gson is easiest to use to send and parse JSON.

    {"userId":"guest1","timestamp":"2010-07-01 08:58:23","wifi":[{"ssid":"guest","rssi":"40"},{"ssid":"guest1","rssi":"80"}]}
    

    You should use a JSON object having a JSON array as one of its items. The JSON array in turn contains another json object.

    If you are using Google GSON, you should build a class hierarchy for the same. Heres how you should do the same.

    Class data{
    
     String userId;
     String timestamp;
     Wifi wifi;
    }
    
    Class Wifi{
    
     String ssid;
     int rssi;
    }
    

    You can check here for a sample code on a similar problem on parsing json in android.

    This may be useful too.

    0 讨论(0)
提交回复
热议问题