java - Parse Bundle data -


i'm using gcm in app , i'm sending datas server client. data this:

{ registration_id: '',   time_to_live: 60,   'data.type': 'newprocess',   'data.sessionid': 'fd1eceb1-e065-4d9e-9bda-50aecaf89b68',   'data.questions':     [ { question: 'q', answers: ['a', 'b', 'c'], correctanswer: 1 },      { question: 'k', answers: ['a', 'b', 'c'], correctanswer: 1 } ],   'data.users': [] } 

i'm getting data in gcmlistener:

@override public void onmessagereceived(string from, bundle data) {     //parse data come server } 

how can parse data object? couldn't find information , i'm searching hours.

thanks.


solved. article helped , used json.stringfiy in server.

http://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html

this basic example using jsonobject:

@override public void onmessagereceived(string from, bundle data) {      string myjsonstring = data.getstring("myjson");      jsonobject myjson = new jsonobject(myjsonstring);      int registration_id = myjson.optint("registration_id ");     string time_to_live = myjson.optstring("time_to_live"); } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -