2017-12-27 14 views
-2

Ich habe zwei Aktivitäten erstellt: eine für die Anmeldung und eine zweite für die Navigation Schublade. Aber wenn ich mich anmelde, akzeptiert es E-Mail und Passwort, geht aber nicht weiter, es zeigt an, dass die App gestoppt wurde.Log-in Aktivität geht nicht nach der Anmeldung nächste Aktivität

Mein Login-Code:

public class LoginActivity extends AppCompatActivity implements  
View.OnClickListener { 
private final AppCompatActivity activity = LoginActivity.this; 

private NestedScrollView nestedScrollView; 

private TextInputLayout textInputLayoutEmail; 
private TextInputLayout textInputLayoutPassword; 

private TextInputEditText textInputEditTextEmail; 
private TextInputEditText textInputEditTextPassword; 

private AppCompatButton appCompatButtonLogin; 

private AppCompatTextView textViewLinkRegister; 

private InputValidation inputValidation; 
private DatabaseHelper databaseHelper; 

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

    initViews(); 
    initListeners(); 
    initObjects(); 
} 

/** 
* This method is to initialize views 
*/ 
private void initViews() { 

    nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView); 

    textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail); 
    textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword); 

    textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail); 
    textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword); 

    appCompatButtonLogin = (AppCompatButton) findViewById(R.id.appCompatButtonLogin); 

    textViewLinkRegister = (AppCompatTextView) findViewById(R.id.textViewLinkRegister); 

} 

/** 
* This method is to initialize listeners 
*/ 
private void initListeners() { 
    appCompatButtonLogin.setOnClickListener(this); 
    textViewLinkRegister.setOnClickListener(this); 
} 

/** 
* This method is to initialize objects to be used 
*/ 
private void initObjects() { 
    databaseHelper = new DatabaseHelper(activity); 
    inputValidation = new InputValidation(activity); 

} 

/** 
* This implemented method is to listen the click on view 
* 
* @param v 
*/ 
@Override 
public void onClick(View v) { 
    switch (v.getId()) { 
     case R.id.appCompatButtonLogin: 
      verifyFromSQLite(); 
      break; 
     case R.id.textViewLinkRegister: 
      // Navigate to RegisterActivity 
      Intent intentRegister = new Intent(getApplicationContext(), RegisterActivity.class); 
      startActivity(intentRegister); 
      break; 
    } 
} 

/** 
* This method is to validate the input text fields and verify login credentials from SQLite 
*/ 
private void verifyFromSQLite() { 
    if (!inputValidation.isInputEditTextFilled(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) { 
     return; 
    } 
    if (!inputValidation.isInputEditTextEmail(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) { 
     return; 
    } 
    if (!inputValidation.isInputEditTextFilled(textInputEditTextPassword, textInputLayoutPassword, getString(R.string.error_message_email))) { 
     return; 
    } 

    if (databaseHelper.checkUser(textInputEditTextEmail.getText().toString().trim() 
      , textInputEditTextPassword.getText().toString().trim())) { 

     Intent accountsIntent = newIntent(activity,NavigationDrawer.class); 

     startActivity(accountsIntent); 

    } else { 
     // Snack Bar to show success message that record is wrong 
     Snackbar.make(nestedScrollView, getString(R.string.error_valid_email_password), Snackbar.LENGTH_LONG).show(); 
    } 
} 

/** 
* This method is to empty all input edit text 
*/ 
private void emptyInputEditText() { 
    textInputEditTextEmail.setText(null); 
    textInputEditTextPassword.setText(null); 
    } 
} 

Navigationsleiste:

 public class NavigationDrawer extends Activity { 
     private DrawerLayout mDrawerLayout; 
     private ActionBarDrawerToggle nToggle; 
     private ActionBar supportActionBar; 

     @Override 
public void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_navigation_drawer); 
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer); 
    nToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close); 
    mDrawerLayout.addDrawerListener(nToggle); 
    nToggle.syncState(); 
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
} 

@Override 
public boolean onOptionsItemSelected(MenuItem items){ 
    if(nToggle.onOptionsItemSelected(items)) { 
     return true; 
    } 
     return super.onOptionsItemSelected(items); 
    } 

public ActionBar getSupportActionBar() { 
    return supportActionBar; 
} 
} 

} 

Wie kann ich dieses Problem beheben?

+4

posten Sie Ihre Crashlog – shravani

+1

Hallo, was Ausnahme ist? – MilanNz

+0

poste die logcats. – InziKhan

Antwort

0

Es gibt folgende Fragen:

  1. Entwickler nicht Namen zweite Aktivität in Manifest Datei initialisiert wurden.

  2. Verwendeten „dieses“ in der zweiten Tätigkeit nicht für getsupportActionBar() bekommen

+0

@as M.Umer reagieren, es ist korrekt. –

Verwandte Themen