1.

Why Google is using  MVVM over MVP?

Answer»

When you need to execute some background WORK fast and need a guarantee of that execution, create WorkerManager. Work manager APIs GO beyond the only current state of the task and allows tasks to return data in key-value format. We are using LiveData to return data and state of Work. By using WorkManager, our activity can observe livedata and it will get notified whenever the task is finished.

For creating WorkManager, we need to create one subclass of the Worker class. This class has one abstract method called doWork(). As the NAME SUGGESTS, you need to perform the work you want to do in the background. This method will be called in the background/worker thread. Write a program to perform the task in this method.

In return, you have to return WorkerResult. Returning WorkerResult.SUCCESS indicates that the task you PERFORMED completed successfully. Returning WorkerResult.RETRY tells WorkManager to retry the work again. Returning WorkerResult.FAILURE indicates one or more errors occurred.

We can use  WorkManager for:

  • Uploading logs
  • Applying filters to images and saving the image
  • Periodically syncing local data with the network


Discussion

No Comment Found

Related InterviewSolutions