G
G
gleb shtraus2021-01-31 14:08:02
Java
gleb shtraus, 2021-01-31 14:08:02

How to find out why the application crashes in the android studio emulator?

private void getNotes() {
        @SuppressLint("StaticFieldLeak")
        class GetNotesTask extends AsyncTask<Void, Void, List<Note>> {
 
            @Override
            protected List<Note> doInBackground(Void... voids) {
                return NoteDatabase.getDatabase(getApplicationContext())
                        .noteDao().getAllNotes();
            }
 
            @Override
            protected void onPostExecute(List<Note> notes) {
                super.onPostExecute(notes);
//                if (noteList.size() == 0) {
//                    noteList.addAll(notes);
//                    notesAdapter.notifyDataSetChanged();
//                } else {
//                    noteList.add(0, notes.get(0));
//                    notesAdapter.notifyItemInserted(0);
//                }
//                notesRecyclerView.smoothScrollToPosition(0);
          Log.d("MY_NOTES",notes.toString());
            }
        }
     new GetNotesTask().execute();
    }

The application constantly crashes as soon as I comment these lines and start everything works. The compiler does not give any errors and gradle builds everything fine. The database here is roomdatabase.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question