簡體   English   中英

嘗試發送時,Android JSONObject變為null

[英]Android JSONObject becomes null when trying to send

當我嘗試將JSONObject推入數據流時,並且已經正確構建了JSONObject ,但是隨后我嘗試將其發布到流中,因此它為null。

JSONObject position = new JSONObject();

        try {
            position.put("lat", location.getLatitude());
            position.put("lng", location.getLongitude());
        } catch (JSONException e) {
            System.out.println("json not work");
            e.printStackTrace();
        }
        System.out.println(position) //result: {"lat":37,"lng":-122}
        pubNub.publish().message(position)//never sent, if other type it works

嘗試pubNub.publish().message(position.toString());

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM