Httppost在android java

时间:2016-06-13 13:48:30

标签: java android json firebase-cloud-messaging

    https://fcm.googleapis.com/fcm/send     
    Content-Type:application/json
   Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
   { "data": {
     "score": "5x1",
         "time": "15:10"   },  
        "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..." }

如何使用httppost将此json从Android应用程序发送到url direclty

1 个答案:

答案 0 :(得分:0)

您需要格式化和解析JSON,例如,将其转换为String或HashMap列表。然后使用AsyncTask创建HTTP请求(使用POST)。 查看此链接Sending HTTP Post Request with Android 并在NameValuePair.add()中传递表示您要发送的JSON的字符串列表。

进入值:

 HttpResponse response = httpclient.execute(httppost);

您拥有HTTP POST请求的结果(例如String或其他json)。