@@ -30,7 +30,7 @@ import java.util.concurrent.CountDownLatch
3030import java.util.concurrent.TimeUnit
3131
3232/* * Collection of utility methods for interacting with activities. */
33- private val TAG = " ActivityUtil"
33+ private const val TAG = " ActivityUtil"
3434
3535/* *
3636 * Detects if configuration changes are handled by the activity.
@@ -42,7 +42,7 @@ private val TAG = "ActivityUtil"
4242 */
4343@RestrictTo(Scope .LIBRARY )
4444fun Activity.isConfigurationChangeHandled (configBit : Int ): Boolean {
45- val activityInfo = this .getPackageManager() .getActivityInfo(this .getComponentName() , 0 )
45+ val activityInfo = this .packageManager .getActivityInfo(this .componentName , 0 )
4646 return (activityInfo.configChanges and configBit) != 0
4747}
4848
@@ -60,11 +60,12 @@ fun getResumedActivityOrNull(): Activity? {
6060 val activities: Collection <Activity > =
6161 ActivityLifecycleMonitorRegistry .getInstance().getActivitiesInStage(Stage .RESUMED )
6262 if (activities.size > 1 ) {
63- val activityNames = activities.map { it.getLocalClassName() }
63+ val activityNames = activities.map { it.localClassName }
6464 Log .d(
6565 TAG ,
66- " More than one activity was found in the RESUMED stage. Activities found: $activityNames "
66+ " More than one activity was found in the RESUMED stage. Activities found: $activityNames " ,
6767 )
68+ activity = activities.first()
6869 } else if (activities.isEmpty()) {
6970 Log .d(TAG , " No activity found in the RESUMED stage. Waiting up to 2 seconds for one." )
7071 val latch = CountDownLatch (1 )
0 commit comments