[Solved] Why can’t able to use if/else in AsyncTask? [closed]

The if is not in any method. It’s just lose at the class level. Put it inside the do in background or better yet its own method: private String getUrl(Double lat, Double long) { if(lat != null && lng!= null) { String URL = “http://xyz.in/api/stores/around_me.json?app_id=test&lat=” + lat + “&lng=” + lng; return URL; } else … Read more

[Solved] TextView isn’t updated with JSON Response

GetYouTubeUserCommentsTask task = new GetYouTubeUserCommentsTask(null, viewCount); // passing null. And you have public GetYouTubeUserCommentsTask(Handler replyTo, String username) { this.replyTo = replyTo; // replyTo is null this.username = username; } replyTo is null. You need to Initialize the handler replyTo 10 solved TextView isn’t updated with JSON Response

[Solved] How to execute the asynchronous task several times?

You can iterate through the list size and call asynchronous task in that. for(int i=0; i<list.size();i++) { // Call AsyncTask with any value you want to pass // just generate a constructor accordingly new AsyncTask(i).execute(); } And get the value in AsyncTask class with required constructor : public class AsyncTask{ Integer position; public AsyncTask(Integer passedValue) … Read more

[Solved] How Retrofit library working faster than default AsyncTask? [closed]

Async task execute serially and are single threaded by default and they will wait for last call to complete before execution of next one and designed in a way so that to avoid common errors due to parallel running threads. Retrofit is not. It sends calls parallely and use ThreadPoolExecutor. 1 solved How Retrofit library … Read more