Ben Taliadoros
Ben Taliadoros

Reputation: 9331

Best method for threading in Android?

I have an animation in which triggers an event. This event fires a lot of computing usage and thus stutters the UI.

What I need to do is keep the thread running smoothly. When the event happens it will pass a string down to the thread, perform calculations (including using the audioRecord class) and return a boolean variable.

I have looked around and it seems AsyncTask may be the best solution, but I wanted to see if any of you had any ideas? Considering performance, Is this the best way to go?

Thanks,

Ben

Upvotes: 3

Views: 214

Answers (1)

Michele
Michele

Reputation: 6131

Generally AsyncTask is fine. But if you dont need to acess the UI thread for your background operation you can simply use a new thread.

new Thread(new Runnable() {
    public void run() {
        //do stuff
    }
}).start();

Upvotes: 7

Related Questions