Android: Onclick Startactivity Works Only When There Is No Internet Connection
I have a method on my app which displays random images from the SQLite database, which are fetched from the web (JSON). I put an OnClickListener to the image so when it's clicked,
Solution 1:
It's just a blind shot - probably when you haven't internet connection your onCreate() your app gets answer very quick (I assume, that first listing is from onCreate method of your activity. If there is connection it waits for timeout (data doesn't load on some reason).
Generally speaking, it's not good idea to download data using main UI thread. Much better approach is to shift this work to another thread - in this case you probably need to become familiar with AsyncTask
class.
Post a Comment for "Android: Onclick Startactivity Works Only When There Is No Internet Connection"