[英]How to get all the parameters in following response in Android
我想從這個響應中獲取參數!!
Bundle[{custom={"custom data":{"notification_type":"offer","offer_id":4348}}, from=1013970362419, badge=1, message=birds view, android.support.content.wakelockid=4, collapse_key=do_not_collapse}]
我想要offer_id和notification_id ,在上面的通知數據中
由於在Bundle
收到響應,因此您無法直接解析它。 相反,無論數據類型如何,您都可以使用bundle.getString(key)或bundle.getInt(key)獲取 bundle 的每個參數。
因此,在您獲取offer_id
的響應中,首先將自定義參數提取為字符串並將其轉換為JSONObject
。 然后您將能夠獲得offer_id
。
例如
JSONObject keyData = new JSONObject(data.getString("custom"));
Gson gson = new Gson();
KeyValueModel keyValue= gson.fromJson(keyData.toString(), KeyValueModel .class);
String offerId = keyValue.getString("offer_id")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.