Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0526e4a authored by Raff Tsai's avatar Raff Tsai
Browse files

Fix print page starts multiple activities

- Finish old activity when user select new user profile to start a
new activity

Fixes: 140154015
Test: manual
Change-Id: I4f05af4dd8a489c4a563cb51428d8a1277f95cd3
parent 1e719a57
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.print;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -49,12 +50,14 @@ public abstract class ProfileSettingsPreferenceFragment extends SettingsPreferen
                        long id) {
                    final UserHandle selectedUser = profileSpinnerAdapter.getUserHandle(position);
                    if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
                        final Activity activity = getActivity();
                        Intent intent = new Intent(getIntentActionString());
                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                        getActivity().startActivityAsUser(intent, selectedUser);
                        activity.startActivityAsUser(intent, selectedUser);
                        // Go back to default selection, which is the first one
                        spinner.setSelection(0);
                        activity.finish();
                    }
                }