public class TodaySliderViewModel extends ViewModel {
    String TAG = "TodaySliderViewModel";
    AppCompatActivity mActicity;
    public static MutableLiveData<List<TodaySliderImagesModel.Slider_data>> liveBrokerList;
    ApiCallInterface callApi;
    Context context;
    public void initialize(Context con, AppCompatActivity activity, ApiCallInterface ca) {
        context = con;
        mActicity = activity;
        callApi = ca;
    }
    public static LiveData<List<TodaySliderImagesModel.Slider_data>> getTodaySliderImageList() {
        if (liveBrokerList == null) {
            liveBrokerList = new MutableLiveData<>(new ArrayList<>());
        }
        return liveBrokerList;
    }
    public LiveData<List<TodaySliderImagesModel.Slider_data>> getAPITodaySliderImageList() {
        if (liveBrokerList == null) {
            liveBrokerList = new MutableLiveData<>(new ArrayList<>());
        }
        getTodaySliderImage();
        return liveBrokerList;
    }
    public void getTodaySliderImage() {
        callApi.onCall();
        ApiInterface apiInterface = APIClient.getClient().create(ApiInterface.class);
        Call<TodaySliderImagesModel> call = apiInterface.getTodaySliderImageList();
        Rohit.LOG(TAG, "getTodaySliderImageList list url " + call.request());
        call.enqueue(new Callback<TodaySliderImagesModel>() {
            @Override
            public void onResponse(Call<TodaySliderImagesModel> call, Response<TodaySliderImagesModel> response) {
                //    Rohit.LOG(TAG, "getSearchShopList list response " + response.body().msg);
                if (!response.isSuccessful()) {
                    Toast.makeText(context, "Contact Admin", Toast.LENGTH_SHORT).show();
                    callApi.onFailed("getBrokerList list error ");
                } else {
                    TodaySliderImagesModel model = response.body();
                    if (model.status.equalsIgnoreCase("200")) {
                        liveBrokerList.setValue(model.slider_data);
                        callApi.onSuccessResponse(model.msg);
                        Rohit.LOG(TAG, "Total getBrokerList :-" + String.valueOf(model.slider_data.size()));
                    } else {
                        callApi.onFailed( response.body().msg);
                    }
                }
            }
            @Override
            public void onFailure(Call<TodaySliderImagesModel> call, Throwable t) {
                callApi.onFailed("getBrokerList list error " + t.getMessage());
                Rohit.LOG(TAG, "getBrokerList list error " + t.getMessage());
            }
        });
    }
}




activity in ini view model ...



TodaySliderViewModel todaySliderViewModel = new ViewModelProvider(this).get(TodaySliderViewModel.class);
        todaySliderViewModel.initialize(context, SplashScreenActivity.this, SplashScreenActivity.this);
        todaySliderViewModel.getAPITodaySliderImageList().observe(this, new Observer<List<TodaySliderImagesModel.Slider_data>>() {
            @Override
            public void onChanged(List<TodaySliderImagesModel.Slider_data> brokerList1) {

            }
        });





other activity get Data (using static array )  :- 




TodaySliderViewModel.getTodaySliderImageList().observe(this, new Observer<List<TodaySliderImagesModel.Slider_data>>() {
            @Override
            public void onChanged(List<TodaySliderImagesModel.Slider_data> sliderDataList) {
                //  Toast.makeText(context, String.valueOf(brokerList1.size()), Toast.LENGTH_SHORT).show();
                sliderImageList.addAll(sliderDataList);
                if (!sliderImageList.isEmpty()) {
                    for (int i = 0; i < sliderDataList.size(); i++) {
                        TodaySliderImagesModel.Slider_data model = sliderDataList.get(i);
                        list.add(new CarouselItem(model.couple_image,
                                "")
                        );
                    }
                    setImageSlider();

                }
            }
        });