ok so im very new to android development and fairly new to java and i dont fully understand threads and inner classes and such.
i have my main activity (MyActivity) with all my ui stuff in it.
i have an inner class (MyTask) extends AsyncTask with a thread running that changes the ui
public final class MyActivity extends Activity{
blah..
class MyTask extends AsyncTask<Integer, Integer, Void>{
@Override
protected Void doInBackground(Integer... params) {
t = new Thread(){
@Override
public void run() {
while(true) {
//do ui change stuff here
this works fine.
i would like to play a sound using AudioTrack in streaming mode that is triggered by the events in MyTask.
however this will interfere with the ui stuff.
whats the best way to handle the sound playing code so it doesnt slow the ui down?
thank you
My original suggestion would have been to use a service however, upon researching it looks like that won’t be the right direction to go.
from: http://developer.android.com/reference/android/app/Service.html
Based on the threads link from the link above I would suggest a worker thread, you can find it here:
http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html
As long as you’re not planning on updating UI elements from it, if so there are additional suggestions/links under the worker thread heading that describe additional considerations.
Good luck, I hope this helps