package androidx.lifecycle;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import java.util.concurrent.atomic.AtomicBoolean;

/* loaded from: classes.dex */
public final class q {

    /* renamed from: a, reason: collision with root package name */
    public static final q f4883a = new q();

    /* renamed from: b, reason: collision with root package name */
    private static final AtomicBoolean f4884b = new AtomicBoolean(false);

    /* loaded from: classes.dex */
    public static final class a extends j {
        @Override // androidx.lifecycle.j, android.app.Application.ActivityLifecycleCallbacks
        public void onActivityCreated(Activity activity, Bundle bundle) {
            kotlin.jvm.internal.t.g(activity, "activity");
            m0.f4862q.b(activity);
        }
    }

    private q() {
    }

    public static final void a(Context context) {
        kotlin.jvm.internal.t.g(context, "context");
        if (f4884b.getAndSet(true)) {
            return;
        }
        Context applicationContext = context.getApplicationContext();
        kotlin.jvm.internal.t.e(applicationContext, "null cannot be cast to non-null type android.app.Application");
        ((Application) applicationContext).registerActivityLifecycleCallbacks(new a());
    }
}
