title: solve java.lang.StringIndexOutOfBoundsException: length=82; regionStart=-1; regionLength=82
body: <p>I have a project that should copy a text and past it in mobile. but i see this error and after it my app crashes.</p>
  
  <pre><code>java.lang.StringIndexOutOfBoundsException: length=82; regionStart=-1; regionLength=82
          at java.lang.String.startEndAndLength(String.java:583)
          at java.lang.String.substring(String.java:1464)
          at com.example.util.Dialogs$4.onClick(Dialogs.java:131)
          at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:157)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:137)
          at android.app.ActivityThread.main(ActivityThread.java:5041)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:511)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>This error is for this line of my app:</p>
  
  <pre><code> .setNegativeButton(R.string.text, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                      String suggestion = message.substring(
                              message.indexOf(activity.getString(R.string.start)), message.length() - 1
                      );
  </code></pre>
  
  <p>Please help me.</p>