Search in sources :

Example 11 with OnLifecycleEvent

use of androidx.lifecycle.OnLifecycleEvent in project android_packages_apps_Settings by omnirom.

the class UsbTetherPreferenceController method onStart.

@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
    mMassStorageActive = Environment.MEDIA_SHARED.equals(Environment.getExternalStorageState());
    IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_STATE);
    filter.addAction(Intent.ACTION_MEDIA_SHARED);
    filter.addAction(Intent.ACTION_MEDIA_UNSHARED);
    mContext.registerReceiver(mUsbChangeReceiver, filter);
}
Also used : IntentFilter(android.content.IntentFilter) OnLifecycleEvent(androidx.lifecycle.OnLifecycleEvent)

Example 12 with OnLifecycleEvent

use of androidx.lifecycle.OnLifecycleEvent in project android_packages_apps_Settings by omnirom.

the class DataDuringCallsPreferenceController method onResume.

@OnLifecycleEvent(ON_RESUME)
public void onResume() {
    if (mChangeListener == null) {
        mChangeListener = new SubscriptionsChangeListener(mContext, this);
    }
    mChangeListener.start();
    if (mMobileDataContentObserver == null) {
        mMobileDataContentObserver = new MobileDataContentObserver(new Handler(Looper.getMainLooper()));
        mMobileDataContentObserver.setOnMobileDataChangedListener(() -> refreshPreference());
    }
    mMobileDataContentObserver.register(mContext, mSubId);
}
Also used : MobileDataContentObserver(com.android.settings.network.MobileDataContentObserver) SubscriptionsChangeListener(com.android.settings.network.SubscriptionsChangeListener) Handler(android.os.Handler) OnLifecycleEvent(androidx.lifecycle.OnLifecycleEvent)

Aggregations

OnLifecycleEvent (androidx.lifecycle.OnLifecycleEvent)12 IntentFilter (android.content.IntentFilter)10 TetheringManager (android.net.TetheringManager)1 Handler (android.os.Handler)1 HandlerExecutor (android.os.HandlerExecutor)1 Window (android.view.Window)1 WindowManager (android.view.WindowManager)1 RotationPolicy (com.android.internal.view.RotationPolicy)1 MobileDataContentObserver (com.android.settings.network.MobileDataContentObserver)1 SubscriptionsChangeListener (com.android.settings.network.SubscriptionsChangeListener)1