diff --git a/core/tests/powertests/PowerStatsViewer/src/com/android/frameworks/core/powerstatsviewer/PowerStatsViewerActivity.java b/core/tests/powertests/PowerStatsViewer/src/com/android/frameworks/core/powerstatsviewer/PowerStatsViewerActivity.java index 78f2b9135d0c3..05679101f86a8 100644 --- a/core/tests/powertests/PowerStatsViewer/src/com/android/frameworks/core/powerstatsviewer/PowerStatsViewerActivity.java +++ b/core/tests/powertests/PowerStatsViewer/src/com/android/frameworks/core/powerstatsviewer/PowerStatsViewerActivity.java @@ -29,6 +29,7 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.activity.ComponentActivity; +import androidx.activity.result.ActivityResultLauncher; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.loader.app.LoaderManager; @@ -60,6 +61,8 @@ public class PowerStatsViewerActivity extends ComponentActivity { private RecyclerView mPowerStatsDataView; private View mLoadingView; private View mEmptyView; + private ActivityResultLauncher mStartAppPicker = registerForActivityResult( + PowerConsumerPickerActivity.CONTRACT, this::onApplicationSelected); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -105,8 +108,7 @@ public class PowerStatsViewerActivity extends ComponentActivity { } private void startAppPicker() { - registerForActivityResult(PowerConsumerPickerActivity.CONTRACT, this::onApplicationSelected) - .launch(null); + mStartAppPicker.launch(null); } private void onApplicationSelected(String powerConsumerId) {