A SQLite database has fields to store Latitude and Longitude values in a table. A mailing address is input from users in an Add dialog.
In the AsyncTask
that fetches the LatLng object for the input address, the database write operation is the last statement of its doInBackground
method. However, contrary to expectation, the write is happening BEFORE the JSON parsing of the response, writing NULL values for the lat and long initially.
The ListView
that front-ends the table shows null Lat and Long values, but the right values after a refresh. The focus rushes back from the Add dialog before the JSON parsing and all, which is not the desired behaviour. The ListView
must return only after the right LatLng are populated in the table, until which an indeterminate progress bar should keep showing. This IS all working fine, except that
- the progress bar appears and vanishes too fast
- The
ListView
is back with other components of its list items properly populated, except the LatLong values.
The question is, how can the database write be forced to wait till the JSON parsing is complete?
Hope this verbose explanation of the situation will suffice. Please mention if more elaboration or code is required.
Many thanks in advance!
Aucun commentaire:
Enregistrer un commentaire