So I've figured out the issue.
On the manifest after adding android:launchMode="singleTask"
to the starting activity, it fixed my problem.
Thanks to Chris I was able to focus more on the Manifest to find out the error.
Frage
Hello I have a small problem with my app.
The starting activity connects to the sqlite database and retrieves an integer number that will check latter if it's 0, 1 or 2. Depending on the number, it will then open the respective activity.
final DatabaseHandler db = new DatabaseHandler(this); // Connection to the DB
final GokeyPin pinrow = db.getPin(1); // Grabs Pin + Pin Check + ID
int pin_check = pinrow.getYN(); //Grabs Pin Check | 0 = Never made a Pin | 1 = Has a pin | 2 = Doesn't want to have pin activated
//Checks if you have created a pin
if(pin_check==0) {
// If 0 that means you haven't created a pin, so it brings you to the Createpin activity
Intent intent = new Intent(Start.this, Createpin.class);
startActivity(intent);
}
// Checks if you have the pin active.
if(pin_check==1) {
// If 1 that means you want to use a pin and you have a pin. Goes to LogIn activity
Intent intent2 = new Intent(Start.this, Login.class);
startActivity(intent2);
}
// Now it checks if you don't want to use a pin. That is 2. If so, it goes to Home activity
if(pin_check==2) {
Intent intent3 = new Intent(Start.this, Home.class);
startActivity(intent3);
}
Then I update in the settings activity the number in the SQLite, and I exit with the back button from the device.
//In setting, checks if you have option to use or not a PIN
RadioGroup radioGroup2 = (RadioGroup) findViewById(R.id.radioGroupUsePin);
int id2 = radioGroup2.getCheckedRadioButtonId();
if (id2 == -1){
//no item selected
}
//If user has option NO selected
if (id2 == R.id.radioUPNo){
// Grabs Pin + Pin Check + id from DB
final GokeyPin pinrow2 = db.getPin(1);
//Updates Pin check -> 2 = mean not using
pinrow2.setYN(2);
db.updatePin(pinrow2);
}
// If Yes is selected
if (id2 == R.id.radioUPYes){
// Grabs Pin + Pin Check + id From DB
final GokeyPin pinrow2 = db.getPin(1);
//Updates Pin check - 1 = means using pin
pinrow2.setYN(1);
db.updatePin(pinrow2);
}
Then the app saves the changes and I quit the app using the return button
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(true);
return true;
}
return super.onKeyDown(keyCode, event);
}
The problem is that when I start it again, it doesn't change for the activity wanted. For example if I have changed it to not use the pin then it should be going to the home activity, but instead, it still asks to login. If I don't login, but instead, if I use then the return button again, the next time I start the app, then it goes to the home without asking for a login.
The same happens if I have no login and I want to login.
If I go to the task manager after updating the settings and I force quit it, then it works fine.
Lösung
So I've figured out the issue.
On the manifest after adding android:launchMode="singleTask"
to the starting activity, it fixed my problem.
Thanks to Chris I was able to focus more on the Manifest to find out the error.