Abbas
Abbas

Reputation: 3331

AsyncTask Alternative or Interface

I am looking for an alternative to AsyncTask so I can use it(I'm already extending class from Activity) What I'm trying to do is ping to google. Since I can not do it in main thread and can not extend from another class. So what are my options? I googled and found a Service class but the page Here (http://developer.android.com/reference/android/app/Service.html/)! says It is not a thread and is not used to avoid "Not Responding" (as I mentioned earlier I am trying to access Internet) I am using android JellyBeans

Upvotes: 0

Views: 1645

Answers (2)

sai Gorantla
sai Gorantla

Reputation: 179

refer to this post, there is explanation about an alternative for async task

Service

Upvotes: 0

FD_
FD_

Reputation: 12919

What you need is an anonymous class, basically a class inside another one. More specifically, you need an anonymous subclass of AsyncTask in your Activity. An alternative would be to create a subclass of AsyncTask and pass the variables you need as arguments.

There should be no need for making a class subclass of two classes. Rethink your concept.

Upvotes: 1

Related Questions