Search Results

Search found 1 results on 1 pages for 'user2842342'.

Page 1/1 | 1 

  • Creation of AsyncTask taking too much time Android

    - by user2842342
    I am making a network call in an AsyncTask, but the problem i am facing is the amount of time it is taking to start the doInBackground method. Here is a part of my code: button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d("Temp:",System.currentTimeMillis()+""); new Move().execute(); /*some other logic } } And my AsyncTask is: private class Move extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... temp) { Log.d("start:",System.currentTimeMillis()+""); gson.fromJson(Web.Request.get(some_URL),Void.class); Log.d("end:",System.currentTimeMillis()+""); return null; } } These are the logs i got: 32658-998/com.example.game D/temp:? 1408923006159 32658-998/com.example.game D/start:? 1408923035163 32658-998/com.example.game D/end:? 1408923035199 So actually it took almost 29 secs to reach the first line in doInBackground method, where as it took just 36 ms to finish the network call. I tried it many times, the time taken is almost in the same order. Is it possible to start the AsyncTask immediately? Or is there any other way to solve this problem.(other than a running a simple thread?) Thank you :)

    Read the article

1