Parsing bundle from android push notification Parsing bundle from android push notification json json

Parsing bundle from android push notification


In the method that received the intent do this:

protected void onMessage(Context context, Intent intent) {    //log the message in JSON format    Log.i(TAG, "Received message >> " + intent.getExtras().toString());    //Retrieve message and extra    String message = intent.getExtras().getString("message");}


The real JSON Object is this:

{"valid":"bbb","deal":"its working","address":"some","name":"aaa"}

The rest is not actually JSON.

Try to parse just this line, and it will work =)

So:

json = new JSONObject( bundle.getString("message") );


You should use the Bundle's built in functions to get data (getString for example). Try the following code:

String jsonStr = bundle.getString("message");json = new JSONObject(jsonStr);