1

My app does not run, instead shows a white screen on the emulator and I am swamped with skipped frames, as far as I am aware the code in my main thread is relatively simple..

public class MainActivity extends AppCompatActivity {

EditText etEmail, etPassword;
Button signInButton;
UserLocalStore userLocalStore;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.content_main);

    etEmail = (EditText) findViewById(R.id.etEmail);
    etPassword = (EditText) findViewById(R.id.etPassword);
    signInButton = (Button) findViewById(R.id.signInButton);

    userLocalStore = new UserLocalStore(this);

    signInButton.setOnClickListener(
            new Button.OnClickListener() {
                public void onClick(View v) {
                    switch (v.getId()) {
                        case R.id.signInButton:
                            String email = etEmail.getText().toString();
                            String password = etPassword.getText().toString();
                            User user = new User(null, null, email, password);

                            authenticate(user);

                            break;
                    }

                }

                private void authenticate(User user) {
                    ServerRequests serverRequest = new ServerRequests(MainActivity.this);
                    serverRequest.GetUserDataAsyncTask(user, new GetUserCallback() {
                        @Override
                        public void done(User returnedUser) {
                            if (returnedUser == null) {
                                showErrorMessage();
                            } else {
                                logUserIn(returnedUser);
                            }
                        }
                    });
                }

                private void showErrorMessage() {
                    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainActivity.this);
                    dialogBuilder.setMessage("Incorrect user details");
                    dialogBuilder.setPositiveButton("Ok", null);
                    dialogBuilder.show();

                }

                private void logUserIn(User returnedUser) {
                    userLocalStore.storeUserData(returnedUser);
                    userLocalStore.setUserLoggedIn(true);
                    startActivity(new Intent(MainActivity.this, HomeScreenActivity.class));
                }


            }

    );


}

@Override
protected void onStart() {
    super.onStart();

    if (authenticate()) {
        displayUserDetails();
    } else {
        startActivity(new Intent(MainActivity.this, MainActivity.class));
    }
}

private boolean authenticate() {
    return userLocalStore.getUserLoggedIn();
}

private void displayUserDetails() {
    User user = userLocalStore.getLoggedInUser();
    etEmail.setText(user.email);
}

}

Yet I still manage to get hundreds of skipped frames messages i.e:

    02-24 17:45:10.412 3051-3051/k.unionapp I/Choreographer: Skipped 42 frames!  The application may be doing too much work on its main thread.
02-24 17:45:10.917 3051-3051/k.unionapp I/Choreographer: Skipped 40 frames!  The application may be doing too much work on its main thread.
02-24 17:45:11.712 3051-3051/k.unionapp I/Choreographer: Skipped 40 frames!  The application may be doing too much work on its main thread.
02-24 17:45:12.227 3051-3051/k.unionapp I/Choreographer: Skipped 39 frames!  The application may be doing too much work on its main thread.
02-24 17:45:12.746 3051-3051/k.unionapp I/Choreographer: Skipped 35 frames!  The application may be doing too much work on its main thread.
02-24 17:45:13.184 3051-3051/k.unionapp I/Choreographer: Skipped 36 frames!  The application may be doing too much work on its main thread.
02-24 17:45:13.721 3051-3051/k.unionapp I/Choreographer: Skipped 38 frames!  The application may be doing too much work on its main thread.
02-24 17:45:14.167 3051-3051/k.unionapp I/Choreographer: Skipped 37 frames!  The application may be doing too much work on its main thread.
02-24 17:45:14.621 3051-3051/k.unionapp I/Choreographer: Skipped 37 frames!  The application may be doing too much work on its main thread.
02-24 17:45:15.258 3051-3051/k.unionapp I/Choreographer: Skipped 43 frames!  The application may be doing too much work on its main thread.
02-24 17:45:15.813 3051-3051/k.unionapp I/Choreographer: Skipped 48 frames!  The application may be doing too much work on its main thread.
02-24 17:45:16.298 3051-3051/k.unionapp I/Choreographer: Skipped 43 frames!  The application may be doing too much work on its main thread.
02-24 17:45:16.844 3051-3051/k.unionapp I/Choreographer: Skipped 43 frames!  The application may be doing too much work on its main thread.
02-24 17:45:17.595 3051-3051/k.unionapp I/Choreographer: Skipped 76 frames!  The application may be doing too much work on its main thread.
02-24 17:45:18.032 3051-3051/k.unionapp I/Choreographer: Skipped 44 frames!  The application may be doing too much work on its main thread.
02-24 17:45:18.535 3051-3051/k.unionapp I/Choreographer: Skipped 39 frames!  The application may be doing too much work on its main thread.
02-24 17:45:19.163 3051-3051/k.unionapp I/Choreographer: Skipped 45 frames!  The application may be doing too much work on its main thread.
02-24 17:45:19.738 3051-3051/k.unionapp I/Choreographer: Skipped 48 frames!  The application may be doing too much work on its main thread.
02-24 17:45:20.311 3051-3051/k.unionapp I/Choreographer: Skipped 44 frames!  The application may be doing too much work on its main thread.
02-24 17:45:20.868 3051-3051/k.unionapp I/Choreographer: Skipped 43 frames!  The application may be doing too much work on its main thread.
02-24 17:45:21.371 3051-3051/k.unionapp I/Choreographer: Skipped 36 frames!  The application may be doing too much work on its main thread.
02-24 17:45:21.850 3051-3051/k.unionapp I/Choreographer: Skipped 48 frames!  The application may be doing too much work on its main thread.

I just cant get my head around what it is that is causing this problem, any help would be greatly appreciated! Thanks in advance.

kmil
  • 243
  • 3
  • 13

0 Answers0