How to get data while using background sevice

I’m using background service to get data from backendless even when my android app is closed, but nothing return, any help?

my code

Backendless.Data.of(Movie.class).find(new AsyncCallback<List>() {
@Override
public void handleResponse(List response) {
movies = response;

            for (Movie movie : response) {
                names.add(movie.getName());
            }


}

        @Override
        public void handleFault(BackendlessFault fault) {
            Toast.makeText(MyService.this, "Back Service Error", Toast.LENGTH_SHORT).show();
        }
    });

Hi Peter,

Have you tried debugging the code to see if you get either data or an error?

Also, you mentioned the code runs when the app is closed, yet, in case of error you display a Toast. Where would the toast be shown if there is no UI? Can a background service display toast notifications?

Regards,
Mark

1 Like

I found the solution,I should have used (handler.postDelayed) to wait until movies return from backendless, Thank you.