mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 11:02:35 +01:00
Replaced System.Exit calls with FinishAffinity and Start Activity calls
Implemented "RestartApp" method defined in NavigationHelper.java. This method is used in ExitActivity.java and ContentSettingsFragment.java
This commit is contained in:
parent
547a1a9970
commit
90de75968d
@ -6,6 +6,8 @@ import android.content.Intent;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) Hans-Christoph Steiner 2016 <hans@eds.org>
|
* Copyright (C) Hans-Christoph Steiner 2016 <hans@eds.org>
|
||||||
* ExitActivity.java is part of NewPipe.
|
* ExitActivity.java is part of NewPipe.
|
||||||
@ -48,6 +50,6 @@ public class ExitActivity extends Activity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.exit(0);
|
NavigationHelper.restartApp(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||||||
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
||||||
import org.schabi.newpipe.extractor.localization.Localization;
|
import org.schabi.newpipe.extractor.localization.Localization;
|
||||||
import org.schabi.newpipe.streams.io.StoredFileHelper;
|
import org.schabi.newpipe.streams.io.StoredFileHelper;
|
||||||
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.ZipHelper;
|
import org.schabi.newpipe.util.ZipHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -255,7 +256,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||||||
// save import path only on success; save immediately because app is about to exit
|
// save import path only on success; save immediately because app is about to exit
|
||||||
saveLastImportExportDataUri(true);
|
saveLastImportExportDataUri(true);
|
||||||
// restart app to properly load db
|
// restart app to properly load db
|
||||||
System.exit(0);
|
NavigationHelper.restartApp(requireActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Uri getImportExportDataUri() {
|
private Uri getImportExportDataUri() {
|
||||||
|
@ -599,4 +599,16 @@ public final class NavigationHelper {
|
|||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish this <code>Activity</code> as well as all <code>Activities</code> running below it
|
||||||
|
* and then start <code>MainActivity</code>.
|
||||||
|
*
|
||||||
|
* @param activity the activity to finish
|
||||||
|
*/
|
||||||
|
public static void restartApp(final Activity activity) {
|
||||||
|
activity.finishAffinity();
|
||||||
|
final Intent intent = new Intent(activity, MainActivity.class);
|
||||||
|
activity.startActivity(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user