I try to write a library application. I works with php and MySql.
In my mainACtivity, I call function that return 3 lists: books, cart and orders. The first is full, but cart and orders are empty. Theses functions are called in myAsyncTask.
new AsyncTask<Void, Void, ArrayList<Book>>() {
@Override
protected void onPreExecute() {
}
@Override
protected ArrayList<Book> doInBackground(Void... voids) {
listBook = backend.getBookInStock();
billForMember = backend.getBillForMember(member.getMemberID());
cart = backend.getCart(member.getMemberID());
return listBook;
}
@Override
protected void onPostExecute( ArrayList<Book> list) {
searchView = (SearchView) findViewById(R.id.searchView);
listView = (ListView) findViewById(R.id.listView);
bookAdapter = new BookAdapter(CrownLibrary.this, listBook, AccessType.DIRECTOR, SearchType.BOOK_IN_STOCK, 0);
bookAdapter.addListener(CrownLibrary.this);
listView.setAdapter(bookAdapter);
}
}.execute();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(CrownLibrary.this, CrownLibraryDetails.class);
intent.putExtra(IntentExtra.BOOK.toString(), bookAdapter.getItem(i));
intent.putExtra(IntentExtra.MEMBER.toString(), member);
startActivity(intent);
}
});
When I debug my application, the function calls theses 3 functions, and initializes them well. But just after doInBackground, the application doesn't effectuate onPOstExecute. I know this, because the listView (whose is in onPostExecute) is never initialized and the application stops.
01-17 17:28:25.956 8002-8002/com.example.lilo.ebookstore E/AndroidRuntime: Caused by: java.lang.NullPointerException
01-17 17:28:25.956 8002-8002/com.example.lilo.ebookstore E/AndroidRuntime: at com.example.lilo.ebookstore.CrownLibrary.onCreate(CrownLibrary.java:94)
I don't have any idea.