What is a StringIndexOutOfBoundsException? How can I fix it?
<p>This is my code:</p>

<pre><code>    private void bringData() {
    final TextView mTextView = (TextView) findViewById(R.id.textView);

    // Instantiate the RequestQueue.
    RequestQueue queue = Volley.newRequestQueue(this);
    String url ="http://192.168.4.1:8080/";

    // Request a string response from the provided URL.
    StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
            new Response.Listener&lt;String&gt;() {
                @Override
                public void onResponse(String response) {
                    // Display the first 500 characters of the response string.
                    mTextView.setText("Response is: "+ response.substring(0,500));
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            mTextView.setText("That didn't work!");
        }
    });
    // Add the request to the RequestQueue.
    queue.add(stringRequest);
}
</code></pre>

<p>It's the default given from the android documentation. I only changed the url. </p>

<p>This is my error message:</p>

<blockquote>
  <p>java.lang.StringIndexOutOfBoundsException: length=28; regionStart=1;
  regionLength=499
                        at java.lang.String.substring(String.java:1931)
                        at com.example.my.app.MainActivity$2.onResponse(MainActivity.java:50)
                        at com.example.my.app.MainActivity$2.onResponse(MainActivity.java:46)
                        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
                        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
                        at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
                        at android.os.Handler.handleCallback(Handler.java:751)
                        at android.os.Handler.dispatchMessage(Handler.java:95)
                        at android.os.Looper.loop(Looper.java:154)
                        at android.app.ActivityThread.main(ActivityThread.java:6077)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)</p>
</blockquote>

<p>During debugging I see that at <code>mTextView.setText("Response is: "+ response.substring(0,500));</code> my message is delivered to me but the textview is never updated and the app crashes.</p>

<p>Specifically, it crashes here inside the Looper.Java file:</p>

<pre><code>finally {
if (traceTag != 0) {
   Trace.traceEnd(traceTag);
} 
</code></pre>

<p>traceTag is 0.</p>

<p>I read that some string bounds are wrong but I cannot find out how to fix it. </p>