android:label="@string/app_name"
android:theme="@style/ApplicationTheme"
android:networkSecurityConfig="@xml/network_security_config"
+ android:enableOnBackInvokedCallback="true"
android:allowBackup="false" >
<activity
android:name=".ui.MainActivity"
import org.strongswan.android.data.VpnProfileDataSource;
+import androidx.activity.OnBackPressedCallback;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
+ getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true)
+ {
+ @Override
+ public void handleOnBackPressed()
+ {
+ prepareResult();
+ finish();
+ }
+ });
+
FragmentManager fm = getSupportFragmentManager();
mApps = (SelectedApplicationsListFragment)fm.findFragmentByTag(LIST_TAG);
if (mApps == null)
return super.onOptionsItemSelected(item);
}
- @Override
- public void onBackPressed()
- {
- prepareResult();
- super.onBackPressed();
- }
-
private void prepareResult()
{
Intent data = new Intent();