Connecting to API stops animation

I connect with my API (written in PHP) and that stops my game animation for 2 seconds. I used the AsyncTask() method but it doesn’t work… How to fix it?

I used this solution: