プログレスバーが表示された後にログインを実装しようとしていますが、エラーが表示されます.Belowは私が使用しているコードです
class PostService extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String s = UserFunctions.response;
Log.d(Details.TAG, "checking i response...");
UserFunctions.basicLogin(email, password);
Log.d(Details.TAG,
s + " " + UserFunctions.basicLogin(email, password));
return s;
}
Intent i;
@Override
protected void onPostExecute(String r) {
// TODO Auto-generated method stub
super.onPostExecute(UserFunctions.response);
Log.d(Details.TAG, "Password Point");
if(UserFunctions.basicLogin(email, password)){
i = new Intent("com.example.eve_haps.DASHBOARDACTIVITY");
startActivity(i);
}else {
Toast.makeText(MainActivity.this,
"Login UnSuccesful. Check email and/or password",
Toast.LENGTH_SHORT).show();
}
}
}
しかし、それはエラーログを返します
E/AndroidRuntime( 7465): FATAL EXCEPTION: main
E/AndroidRuntime( 7465): java.lang.StringIndexOutOfBoundsException: length=0; regionStart=0; regionLength=17
E/AndroidRuntime( 7465): at java.lang.String.startEndAndLength(String.java:593)
E/AndroidRuntime( 7465): at java.lang.String.substring(String.java:1474)
E/AndroidRuntime( 7465): at com.example.eve_haps.UserFunctions.basicLogin(UserFunctions.java:107)
E/AndroidRuntime( 7465): at com.example.eve_haps.MainActivity$PostService.onPostExecute(MainActivity.java:105)
E/AndroidRuntime( 7465): at com.example.eve_haps.MainActivity$PostService.onPostExecute(MainActivity.java:1)
E/AndroidRuntime( 7465): at android.os.AsyncTask.finish(AsyncTask.java:602)
E/AndroidRuntime( 7465): at android.os.AsyncTask.access$600(AsyncTask.java:156)
E/AndroidRuntime( 7465): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
E/AndroidRuntime( 7465): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7465): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 7465): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 7465): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7465): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 7465): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 7465): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 7465): at dalvik.system.NativeStart.main(Native Method)
以下は、ログインを実装するためのコードです
public static boolean basicLogin(String email, String password) {
String msg = "Login successful";
boolean status = false;
String url;
String links[] = {
"..." + "?user=",
"..." + "?actn=login"
+ "&user=" };
auth_link = links[0]+email + "&password=" + password;
response = Connect.doHTTPGet(auth_link);
// result = getHttpResponse(url);
Log.d(Details.TAG, " " + msg.length() + " " + UserFunctions.response.substring(0, 17) + " "+ UserFunctions.response.substring(0, 17).length() );
if (UserFunctions.response.substring(0, 17).trim().equals(msg)) {
Log.d(Details.TAG, " " + msg.length() + " " + UserFunctions.response.substring(0, 17));
status = true;
}
Log.d(Details.TAG, " " + "Connection Test"
+ UserFunctions.response);
return status;
エラーは何ですか。感謝して返信します