[Java for Android App Development] tim91700:
Hello,

I make an FTP client on Android, for a school project.

I have the layout with the name, host, port number, user, pass and the home directory.

I want to handle the ftp format like : ftps://<username>@<hostname>:<port>/<path>/

If the user input ftp:// or ftps://, I want to "delete" inputs and to display input that are missing.

More, if the ftp link have a missing information like the port, the input need to stay, because the format isn't good.

Here is my code :

hote.addTextChangedListener(new TextWatcher() {

public void afterTextChanged(Editable s)
{
//String ftp = "ftps://arthur:@ftp.example.com:990";
if ((s.subSequence(0, 1)).equals("s"))
{
sftp.setChecked(true);
}
//utlisateur=extraitChaine("/",":");
password.setText(extraitChaine(":","@"));
hote.setText(extraitChaine("@",""));
port.setText(extraitChaine(":",""));
}

public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}

public void onTextChanged(CharSequence s, int start,
int before, int count) {

}
// The aim is to extract subsring from char to char
private String extraitChaine(String debut, String fin) {
return "";
}
});

The logcat with a lot of red lines :

05-31 09:11:30.647: D/AndroidRuntime(1944): Shutting down VM
05-31 09:11:30.647: W/dalvikvm(1944): threadid=1: thread exiting with uncaught exception (group=0xb0f76648)
05-31 09:11:30.647: E/AndroidRuntime(1944): FATAL EXCEPTION: main
05-31 09:11:30.647: E/AndroidRuntime(1944): java.lang.IndexOutOfBoundsException: getChars (0 ... 1) ends beyond length 0
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1016)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:913)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.TextUtils.getChars(TextUtils.java:77)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:61)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:905)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at com.example.ynovandroid.activity.InfoFTPActivity$1.afterTextChanged(InfoFTPActivity.java:124)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView.sendAfterTextChanged(TextView.java:7334)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView.setText(TextView.java:3778)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView.setText(TextView.java:3629)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.EditText.setText(EditText.java:80)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView.setText(TextView.java:3604)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at com.example.ynovandroid.activity.InfoFTPActivity$1.afterTextChanged(InfoFTPActivity.java:130)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView.sendAfterTextChanged(TextView.java:7334)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:9087)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:970)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:497)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:223)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView.doKeyDown(TextView.java:5464)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.widget.TextView.onKeyDown(TextView.java:5283)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.KeyEvent.dispatch(KeyEvent.java:2623)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.View.dispatchKeyEvent(View.java:7343)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1933)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1408)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.app.Activity.dispatchKeyEvent(Activity.java:2384)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1860)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3791)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3774)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3516)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3666)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:1982)
05-31 09:11:30.647: E/AndroidRuntime(1944):	at android.view.inputmethod.InputMethodManager.invokeF
05-31 09:11:33.597: D/gralloc_goldfish(1995): Emulator without GPU emulation detected.

I try to test my code, after the first letter, the application stop working.

Can you help me ?