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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:27:27+00:00 2026-06-15T04:27:27+00:00

I am attempting to do a download in an asychronous task in android. Unfortunately

  • 0

I am attempting to do a download in an asychronous task in android. Unfortunately I am getting an “unknownHost’ error. To me it looks like I have the proper permissions but I am still getting this error. Below is my permissions, my error, and the function. Any thoughts on what I am doing wrong?

Thank you very much.

Craig

  11-27 21:51:34.545: D/ImageManager(9381): Error: java.net.UnknownHostException: 

        public void downloadFromUrl(String strUrl, String fileName) { // this is the downloader
        // method
        try {
            File parentDirectory= new File(PATH);
            if (!parentDirectory.exists()) {
                System.err
                        .println("It seems like parent directory does not exist...");
                if (!parentDirectory.mkdirs()) {
                    System.err.println("And we cannot create it...");
                    // we have to return, throw or something else
                }
            }
            URL url = new URL(strUrl);
            File file = new File(PATH + fileName);
            if (!file.exists()) {
                file.createNewFile();
            }

            long startTime = System.currentTimeMillis();
            /* Open a connection to that URL. */
            URLConnection ucon = url.openConnection();

            /*
             * Define InputStreams to read from the URLConnection.
             */
            InputStream is = ucon.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);

            /*
             * Read bytes to the Buffer until there is nothing more to read(-1).
             */
            ByteArrayBuffer baf = new ByteArrayBuffer(50);
            int current = 0;
            while ((current = bis.read()) != -1) {
                baf.append((byte) current);
            }

            /* Convert the Bytes read to a String. */
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(baf.toByteArray());
            fos.close();
            Log.d("ImageManager",
                    "download ready in"
                            + ((System.currentTimeMillis() - startTime) / 1000)
                            + " sec");

        } catch (IOException e) {
            Log.d("ImageManager", "Error: " + e);
        }
    }

     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.craig.musicapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="15" />

.       <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
        <uses-permission android:name="android.permission.GET_ACCOUNTS" />
        <uses-permission android:name="android.permission.USE_CREDENTIALS" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />

    <application
        android:icon="@drawable/jerrygarciahand"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".SearchMusic"
            android:label="@string/search_music"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ConcertDetailActivity"
            android:screenOrientation="portrait" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ItemListActivity" />
        </activity>
        <activity
            android:name=".AppInfo"
            android:label="@string/title_item_list" >
        </activity>
    </application>

</manifest>
  • 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-15T04:27:29+00:00Added an answer on June 15, 2026 at 4:27 am

    So I am a dumb dumb and I figured it out. Amazing what a night of sleep can do.

    My url had “///” instead of “//”. Obviously this was causing an issue with the download. Thank you for all your help and hopefully I won’t get so sleep deprived next time and make such a silly error :).

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

Sidebar

Related Questions

I am attempting to have a progress bar's progress change as the WebClient download
I am attempting to download a URL using NSURLDownload, but it does not start
My wcf client gives me the following error when attempting to download a file
I am building an android game in which I am attempting to download the
I am attempting to just download the html from a webpage, but I want
I'm attempting to download webpages for a user to view later. So far, I've
I'm attempting to use wget with the -p option to download specific documents and
I am attempting to add a function that will create a csv for download
I am attempting to follow http://mondrian.pentaho.com/documentation/developers_guide.php in the download and compilation of the Mondrian
Attempting to build a C# NPAPI plugin I have found a tutorial which describes

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.