@@ -30,7 +30,7 @@ import java.util.concurrent.CountDownLatch
30
30
import java.util.concurrent.TimeUnit
31
31
32
32
/* * Collection of utility methods for interacting with activities. */
33
- private val TAG = " ActivityUtil"
33
+ private const val TAG = " ActivityUtil"
34
34
35
35
/* *
36
36
* Detects if configuration changes are handled by the activity.
@@ -42,7 +42,7 @@ private val TAG = "ActivityUtil"
42
42
*/
43
43
@RestrictTo(Scope .LIBRARY )
44
44
fun Activity.isConfigurationChangeHandled (configBit : Int ): Boolean {
45
- val activityInfo = this .getPackageManager() .getActivityInfo(this .getComponentName() , 0 )
45
+ val activityInfo = this .packageManager .getActivityInfo(this .componentName , 0 )
46
46
return (activityInfo.configChanges and configBit) != 0
47
47
}
48
48
@@ -60,11 +60,12 @@ fun getResumedActivityOrNull(): Activity? {
60
60
val activities: Collection <Activity > =
61
61
ActivityLifecycleMonitorRegistry .getInstance().getActivitiesInStage(Stage .RESUMED )
62
62
if (activities.size > 1 ) {
63
- val activityNames = activities.map { it.getLocalClassName() }
63
+ val activityNames = activities.map { it.localClassName }
64
64
Log .d(
65
65
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 " ,
67
67
)
68
+ activity = activities.first()
68
69
} else if (activities.isEmpty()) {
69
70
Log .d(TAG , " No activity found in the RESUMED stage. Waiting up to 2 seconds for one." )
70
71
val latch = CountDownLatch (1 )
0 commit comments