title: Android. Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
body: <p>I am trying to integrate my application with social network (facebook), and need a little help here. I am trying to get my feed. When I run the application I get a Fatal Exception error.</p>
  
  <pre><code>FATAL EXCEPTION: main
  Process: com.example.vladzakharo.facebookapp, PID: 2428
  java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
       at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
       at org.json.JSONTokener.nextValue(JSONTokener.java:94)
       at org.json.JSONObject.&lt;init&gt;(JSONObject.java:156)
       at org.json.JSONObject.&lt;init&gt;(JSONObject.java:173)
       at com.example.vladzakharo.facebookapp.CentralActivity$2.onCompleted(CentralActivity.java:88)
       at com.facebook.GraphRequest$5.run(GraphRequest.java:1379)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5417)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p>So, this is my class</p>
  
  <pre><code>public class CentralActivity extends AppCompatActivity {
  
  Button btnPublish;
  ListView listView;
  public ArrayList&lt;HashMap&lt;String, String&gt;&gt; list;
  public String Message;
  public  String Name;
  public String Caption;
  public String Description;
  public String Picture;
  public String Link;
  public String Id;
  
  public static final String MESSAGE = "message";
  public static final String NAME = "name";
  public static final String CAPTION = "caption";
  public static final String DESCRIPTION = "description";
  public static final String PICTURE = "picture";
  public static final String LINK = "link";
  public static final String ID = "id";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      FacebookSdk.sdkInitialize(getApplicationContext());
      setContentView(R.layout.activity_central);
  
      list = new ArrayList&lt;&gt;();
      listView = (ListView) findViewById(R.id.listView);
      btnPublish = (Button) findViewById(R.id.btnPublish);
      btnPublish.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Publish();
          }
      });
  
      getFeed();
  }
  
  private void Publish(){
      Intent goPublish = new Intent(CentralActivity.this, PublishActivity.class);
      startActivity(goPublish);
  }
  
  protected void getFeed(){
      new GraphRequest(
              AccessToken.getCurrentAccessToken(),
              "me/feed?fields=message,name,caption,description,picture,link",
              null,
              HttpMethod.GET,
              new GraphRequest.Callback() {
                  @Override
                  public void onCompleted(GraphResponse response) {
                      JSONObject json;
                      try{
                          json = new JSONObject(response.getRawResponse());
                          JSONArray jArray = json.getJSONArray("data");
                          for(int i = 0; i &lt; jArray.length(); i++){
                              Message = jArray.getJSONObject(i).get("message").toString();
                              Name = jArray.getJSONObject(i).get("name").toString();
                              Caption = jArray.getJSONObject(i).get("caption").toString();
                              Description = jArray.getJSONObject(i).get("description").toString();
                              Picture = jArray.getJSONObject(i).get("picture").toString();
                              Link = jArray.getJSONObject(i).get("link").toString();
                              Id = jArray.getJSONObject(i).get("id").toString();
  
                              HashMap&lt;String, String&gt; hm = new HashMap&lt;&gt;();
                              hm.put(MESSAGE, Message);
                              hm.put(NAME, Name);
                              hm.put(CAPTION, Caption);
                              hm.put(DESCRIPTION, Description);
                              hm.put(PICTURE, Picture);
                              hm.put(LINK, Link);
                              hm.put(ID, Id);
                              list.add(hm);
  
                          }
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  }
              }
      ).executeAsync();
      ListAdapter adapter = new SimpleAdapter(this, list, R.layout.list_item,
              new String[]{MESSAGE, NAME, CAPTION, DESCRIPTION },
              new int[]{R.id.text1, R.id.text2, R.id.text3, R.id.text4});
      listView.setAdapter(adapter);
  }
  </code></pre>
  
  <p>}</p>