LifeCycleOwner in Broadcast reciever
Asked Answered
I

0

6

I am using Android Room to store my application data. After device reboot I need to retrieve them and do some functions. I am using LiveData for getting data from database. But I cannot bind Broadcast Reciever as owner. How should I resolve this problem?

public class BootReciever extends BroadcastReceiver {

@Override
public void onReceive(final Context context, Intent intent) {

    if (context != null) {
            ProductUIRepository mRepository = new ProductUIRepository(context.getApplicationContext());
            mRepository.findAllProducts().observe(this, new android.arch.lifecycle.Observer<List<ProductUI>>() {
                @Override
                public void onChanged(@Nullable List<ProductUI> productUIS) {
                    NotificationMan.setAlarmForProducts(context, productUIS);

                }
            });
    }
  }
}

using "this" makes that applications isn't compiling.

Idiocy answered 11/8, 2018 at 17:54 Comment(2)
Did you get this to work? I've run into similar problemLoyola
and nothing yet?Magnificat

© 2022 - 2024 — McMap. All rights reserved.