title: why JSON Exception doesn't be cached in android?
body: <p>i have the follwoing code, but somes times i have the following Exception that doesn't be catched .. what is the reason and the solution ?</p>
  
  <pre><code>12-02 12:03:29.101: ERROR/AndroidRuntime(348): FATAL EXCEPTION: main
  12-02 12:03:29.101: ERROR/AndroidRuntime(348): java.lang.RuntimeException: Unable to start activity ComponentInfo{ayanoo.forms/ayanoo.forms.FriendsActivity}: java.lang.NullPointerException
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.os.Handler.dispatchMessage(Handler.java:99)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.os.Looper.loop(Looper.java:123)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at java.lang.reflect.Method.invokeNative(Native Method)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at java.lang.reflect.Method.invoke(Method.java:521)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at dalvik.system.NativeStart.main(Native Method)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348): Caused by: java.lang.NullPointerException
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:112)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at org.json.JSONTokener.nextValue(JSONTokener.java:90)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at org.json.JSONObject.&lt;init&gt;(JSONObject.java:154)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at org.json.JSONObject.&lt;init&gt;(JSONObject.java:171)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at ayanoo.forms.FriendsActivity.displayFriends(FriendsActivity.java:79)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at ayanoo.forms.FriendsActivity.onCreate(FriendsActivity.java:36)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  12-02 12:03:29.101: ERROR/AndroidRuntime(348):     ... 11 more
  
  
  
  
  
  try {
              //  String searchText = (String) getIntent().getExtras().get("searchTextValue");
              JSONObject jsonObject = new JSONObject(Friend.getFriends(1));
              if(jsonObject!=null)
                      {
                  JSONArray resultsData = jsonObject.getJSONArray("GetFriendsResult");
                  for (int userIndex = 0; userIndex &lt; resultsData.length(); userIndex++) {
                      if (friendsResulted == null) {
                          friendsResulted = new ArrayList&lt;FriendResulted&gt;(resultsData.length());
                      }
                      String[] userArrayData = resultsData.getString(userIndex).split("--!!--");
                      FriendResulted frindAccountResulted = new FriendResulted();
  
                      frindAccountResulted.setFriendId(Integer.parseInt(userArrayData[0]));
                      frindAccountResulted.setUsername(userArrayData[1]);
                      frindAccountResulted.setImagePath(userArrayData[2]);
                      friendsResulted.add(frindAccountResulted);
                      addFriend(frindAccountResulted);
                      counter ++;
                      if(counter&gt;9)break;
                  }
  
  
                  }
              }
  
          catch (JSONException e) {
                  Toast.makeText(this,"Please try again, "+e.getMessage() , Toast.LENGTH_SHORT).show();
                  }
  </code></pre>