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 8520479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:32:54+00:00 2026-06-11T06:32:54+00:00

I have an Asynctask set up to pull icy metadata from shoutcast streams that

  • 0

I have an Asynctask set up to pull icy metadata from shoutcast streams that works great if I put the URL in code, but i want an AlertDialog to pass a URL to the Asynctask from user input. I’m calling AsyncTask like this:

MetadataTask1 metadataTask1 = new MetadataTask1();
metadataTask1.execute(uri);

When I pass ‘uri’ to the Asynctask I get the error,

“The method execute(URL…) in the type
AsyncTask is not applicable for the arguments
(Uri)”

I know a URL is being expected but I can’t figure out how to do it. I’m very new to Android and I’m sure it’s something real simple and dumb.

I have 2 things happening here: User input URL starts the Music Service and plays the stream, and, the same user URL should become a param in the AsyncTask and start pulling icy metadata. Like I said everything works if I manually type a URL into my code but of course this isn’t the idea. My questions are:
1. How do I handle user input (from AlertDialog)….where do I plug it into AsyncTask and how?
2. What about the lines in doInBackground(URL… urls) I’m sure these are wrong:

try {
                    streamMeta.setStreamUrl(new URL(
                            "http://sfstream1.somafm.com:8880"));
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

3 What to do about the Eclipse error when trying to add uri?

Here’s my code:

void showUrlDialog() {

    class MetadataTask1 extends AsyncTask<URL, Void, IcyStreamMeta> {

        @Override
        protected IcyStreamMeta doInBackground(URL... urls)
        {

            try {
                streamMeta.setStreamUrl(new URL(
                        "http://sfstream1.somafm.com:8880")); //I want a variable here from user input
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                streamMeta.refreshMeta();
                Log.e("Retrieving MetaData", "Refreshed Metadata");
            } catch (IOException e) {
                Log.e(MetadataTask1.class.toString(), e.getMessage());
            }
            return streamMeta;
        }

        @Override
        protected void onPostExecute(IcyStreamMeta result) {
            //Toast toast = Toast.makeText(getBaseContext(),
            //      "Electropop and indie dance rock with sparkle and pop.",
            //      Toast.LENGTH_LONG);
            //toast.setGravity(Gravity.BOTTOM, 0, 200);
            //toast.show();

            timer1.schedule(new TimerTask() {
                public void run() {
                    if (timerIsOn1 == true) {
                        try {
                            title_artist = streamMeta.getArtist();
                            title_artist2 = streamMeta.getTitle();
                            Log.e("Retrieved title_artist", title_artist);
                            if (title_artist.length() > 0) {
                                runOnUiThread(new Runnable() {
                                    public void run() {

                                        Main.tx2.setText(title_artist);
                                        Main.tx3.setText(title_artist2);



                                    }

                                });
                            }
                        } catch (IOException e) {
                            Log.e(MetadataTask1.class.toString(),
                                    e.getMessage());
                        }
                        try {
                            streamMeta.refreshMeta();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }

                }
            }, 0, 6000);
        }

    }
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
    alertBuilder.setTitle("Manual Input");
    alertBuilder.setMessage("URL (must be lowercase http://)");
    final EditText input = new EditText(this);
    alertBuilder.setView(input);

    input.setHint("paste your URL here...");

    alertBuilder.setPositiveButton("Play", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dlg, int whichButton) {
            timerIsOn1 = true;

            Main.tx1.setText("user station...");
            Main.tx2.setText("");
            Main.tx3.setText("");

            // Send an intent with the URL of the song to play. This is expected by
            // MusicService.
            final Intent i = new Intent(MusicService.ACTION_URL);
            Uri uri = Uri.parse(input.getText().toString());

            i.setData(uri);
            startService(i);

            progressDialog = ProgressDialog.show(Main.this, "",
                    "connecting...");
            progressDialog.setCancelable(true);

            MetadataTask1 metadataTask1 = new MetadataTask1();
            metadataTask1.execute(uri);
        }
    });

    alertBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dlg, int whichButton) {}
    });

    alertBuilder.show();

}

Thank you if anyone can help me!

  • 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-06-11T06:32:55+00:00Added an answer on June 11, 2026 at 6:32 am

    You declared the type of your AsyncTask as URL, Void, IcyStreamData, but then you’re trying to pass a URI (instead of a URL). You need to convert that URI to a URL. If you’re using java.net.URI then you can try uri.toURL();

    As far as setting the url from the dialog, create your own custom dialog that can send the data from the edittext back to your activity. Then set an onDismissListener on the dialog and when it’s dismissed, check to see if you have a value passed back from the dialog and use that to execute the task. (of course you should/can use regex to validate the url)

    I don’t see why you don’t just use a URL in the first place, but you can try using Uri.Builder and then call builder.build().toString() to have a String for a URL. Or just try uri.toString() and see if that gives you what you need, e.g. URL url = new URL(uri.toString());

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

Sidebar

Related Questions

I have a class that extends AsyncTask , which fetches the gps cordinates from
I have set up the code to call a remote server from Android app
I have an AsyncTask that get info from the web. Sometimes the connection fails
I have the following code that downloads a video using AsyncTask. //DOWNLOAD VIDEOS private
I have an AsyncTask that retrieves information from the internet. But when signal or
So I have this AsyncTask that loads a WebView in onPostExecute that otherwise works
Have the following asynctask that i'm using to download some images. Works fine except
I have an AsyncTask and on the background I want to start Service that
My goal is to have an AsyncTask that can execute multiple times (one task
i have a class extends asynctask private class taskMK extends AsyncTask<Void,Void,JSONObject>{ String url; JSONObject

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.