Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6819449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:18:29+00:00 2026-05-26T21:18:29+00:00

ok so im very new to android development and fairly new to java and

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:18:29+00:00Added an answer on May 26, 2026 at 9:18 pm

    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

    Note that services, like other application objects, run in the main
    thread of their hosting process. This means that, if your service is
    going to do any CPU intensive (such as MP3 playback) or blocking (such
    as networking) operations, it should spawn its own thread in which to
    do that work. More information on this can be found in Processes and
    Threads. The IntentService class is available as a standard
    implementation of Service that has its own thread where it schedules
    its work to be done.
    I may be possible to use the Service in the “intent service” way but that seems like it’s not a common way to use it.

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very very new on Android development. I have designed two xmls layouts (main.xml
I am very new to android development and have been trying to draw a
I am very new to android development.... i have created an app and want
Doing Android development on a Mac and this very new phone I have doesn't
I am very new to Android development. I have this code: Button btnLaunch; btnLaunch=(Button)findViewById(R.id.btnLaunch);
I'm very new on Android development. I have this: AlertDialog.Builder builder = new AlertDialog.Builder(this);
I am really very new on android development. I have made 2-3 apps ,
I very new to Python, and fairly new to regex. (I have no Perl
I am very new to Android development. I am converting my iPhone app to
I everyone. I'm very new to Android development and I want to develop an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.