@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // check request code switch (requestCode) { case INTENT_REQUEST_PASSCODE: boolean isAuthenticated = false; if (resultCode == RESULT_OK && data != null) { Passcode passcode = new Passcode(getApplicationContext()); String passIntent = data.getStringExtra(PasscodeActivity.INTENT_RESULT_PASSCODE); String passDb = passcode.getPasscode(); if (passIntent != null && passDb != null) { isAuthenticated = passIntent.equals(passDb); if (!isAuthenticated) { Toast.makeText(getApplicationContext(), R.string.passocde_no_macth, Toast.LENGTH_LONG) .show(); } } } // close if not authenticated if (!isAuthenticated) { this.finish(); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.base_toolbar_activity); // check if launch from notification if (getIntent() != null && getIntent().getBooleanExtra(INTENT_EXTRA_LAUNCH_NOTIFICATION, false)) { Passcode passcode = new Passcode(getApplicationContext()); if (passcode.hasPasscode()) { Intent intent = new Intent(this, PasscodeActivity.class); // set action and data intent.setAction(PasscodeActivity.INTENT_REQUEST_PASSWORD); intent.putExtra( PasscodeActivity.INTENT_MESSAGE_TEXT, getString(R.string.enter_your_passcode)); // start activity startActivityForResult(intent, INTENT_REQUEST_PASSCODE); } } // set actionbar getSupportActionBar().setDisplayHomeAsUpEnabled(true); // set fragment and fragment manager FragmentManager fm = getSupportFragmentManager(); listFragment = new RecurringTransactionListFragment(); // attach fragment on activity if (fm.findFragmentById(R.id.content) == null) { fm.beginTransaction().add(R.id.content, listFragment, FRAGMENTTAG).commit(); } }