title: How can i return with Content type in laravel?
body: <p>I am trying to use a Laravel application as an Android Studio project.</p>
  
  <p>I am trying to send a httpsrequest from Java, how do I return a response?</p>
  
  <p>Like we use in PHP to return response as JSON as <code>header('Content-Type: application/json');</code> at the header oh .php file and the message as:</p>
  
  <p><code>$response["message"] = "Signin succsessfully done."; 
  echo json_encode($response);</code> </p>
  
  <p>so in laravel i am trying to return response as: </p>
  
  <p><code>return response()-&gt;json(['success'=&gt;1])
       -&gt;header('Content-Type', 'application/json');</code></p>
  
  <p>but it's not working </p>
  
  <p>in my Java file <code>JSONObject json = jsonParser.makeHttpRequest(url, "POST", params);</code></p>
  
  <p>So How do i do this?</p>
  
  <p>edit: this is how i am calling from .java</p>
  
  <pre><code>  JSONObject json = jsonParser.makeHttpRequest(url, "POST", params);
  
          // Check your log cat for JSON reponse
  
          try {
              // Checking for SUCCESS TAG
              success = json.getInt(TAG_SUCCESS);`
   } catch (JSONException e) {
              e.printStackTrace();
          } catch (Exception e) {
              e.printStackTrace();
              System.out.println("Rjn_login_error"+e.getMessage());
          }
  
  
  
  
  
  
  /**
           * After completing background task Dismiss the progress dialog
           * **/
      protected void onPostExecute(String file_url) {
          // dismiss the dialog after getting all products
          pDialog.dismiss();
  
          // updating UI from Background Thread
          runOnUiThread(new Runnable() {
              public void run() {
                  /*
                    Updating parsed JSON data into ListView
                   */
                  if (success == 1) {
                      // jsonarray found
  }}}
  </code></pre>
  
  <p>So when i am using calling the url as <code>http://website.com/test.php</code> and in the <code>test.php</code> `</p>
  
  <pre><code>    $response["success"] = 1;
          $response["message"] = "Signin succsessfully done.";
  
          // echoing JSON response
          echo json_encode($response);
  </code></pre>
  
  <p>and its working perfactly </p>
  
  <p>But when i tried to <code>return response json</code> from laravel controller it's not working ..</p>