How to print the Json object in Android using try block : I need to get the json object from mysql database, and to printed as string,Also i need to pass that string to try block to open required class activity.Here, i have attached my code below, check my code and let me know.

My json object sample:

                      {"id":"381","task":"user_confirm","message":"New booking details"}

My Android Code:

          public void onMessageReceived(final RemoteMessage remoteMessage) {


        Intent intent = new Intent(this, Login_Activity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
        notificationBuilder.setContentTitle(getResources().getString(R.string.app_name));
        notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
        notificationBuilder.setAutoCancel(true);
        notificationBuilder.setSmallIcon(R.mipmap.main_logo);
        notificationBuilder.setContentIntent(pendingIntent);


        Uri path = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bike_start);
        notificationBuilder.setSound(path);
        NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0,notificationBuilder.build());


        if (remoteMessage.getData().size() > 0) {

            try {
                JSONObject json = new JSONObject(remoteMessage.getData());
                Log.e("JsonOutput", json.toString());
                sendNotification(json);
            } catch (Exception e) {
                Log.e(TAG, "Exception: " + e.getMessage());
            }
        }
        if (remoteMessage.getNotification()!=null){

            Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());

        }


         //        sendNotification1(String.valueOf(remoteMessage), image);
          // Log.e("body", body);

            }

          private void sendNotification(JSONObject json) {

        Log.e(TAG, "Notifications JSON1 " + json.toString());
       
        
        try {
             JSONObject data = json.getJSONObject("data");
             Log.d("data", String.valueOf(data));
             //parsing json data
             id = data.get("id").toString();
             message = data.get("message").toString();
             task = data.get("task").toString();
             Log.d("Id values", id);
             Log.d("Message", message);

           }

         }

Output:

  this is what the output what am getting

        Notifications JSON1 {"id":"381","task":"user_confirm","message":"New booking details"}

Thanks@
