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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:14:47+00:00 2026-06-03T03:14:47+00:00

How do I set an array to change the URL of an Async download

  • 0

How do I set an array to change the URL of an Async download task for multiple butons?
This isn’t working and I am not sure how to fix it.

final String[] dlUrl = new String[]{"www.google.com/document.pdf", "www.google.com/document2.pdf", "www.google.com/document3.pdf"};{ 
for(int k = 0; i < dlUrl.length; i++) { 
    final String dlUrl = downloadFile.execute([k]); 


}

I am trying to have it change the following code section:

private void startDownload() {
    DownloadFile downloadFile = new DownloadFile();
    downloadFile.execute("http://www.google.com/doc.pdf");

}

And the Async Task itself:

class DownloadFile extends AsyncTask<String, Integer, String> {

URL url = new URL(aurl[0]);
URLConnection connection = url.openConnection();

I have a similar array that picks up button presses, I want to try to add this to it… Any ideas?

final OnClickListener listener = new OnClickListener() { 
     public void onClick(View v){ 
         switch(v.getId()){  
         case R.id.sec1:  
            break; 
         case R.id.sec2: 
            break; 
         case R.id.sec3: 
            break; 
         } 
     } 
};
final int[] btnIds = new int[]{R.id.sec1, R.id.sec2, R.id.sec3};{ 
for(int i = 0; i < btnIds.length; i++) { 
    final Button btn = (Button) findViewById (btnIds[i]); 
    btn.setOnClickListener(listener); 
}
  • 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-03T03:14:49+00:00Added an answer on June 3, 2026 at 3:14 am
    final String[] dlUrl = new String[]{"www.google.com/document.pdf",
                                        "www.google.com/document2.pdf",
                                        "www.google.com/document3.pdf"};{ 
    
    for(int k = 0; i < dlUrl.length; i++) { 
        final String dlUrl = downloadFile.execute([k]); 
    
    
    }
    

    should probably be something more like

    final String[] dlUrl = new String[]{"www.google.com/document.pdf",
                                        "www.google.com/document2.pdf",
                                        "www.google.com/document3.pdf"}; // { removed
    
    for(int k = 0; k < dlUrl.length; k++) { 
                   ^
    
        final String currentUrl = dlUrl[k];
                                  ^^^^^^^^
    
        downloadFile.execute(currentUrl); 
    }
    

    Regarding your own comment:

    Learning Java and android through trial and error is difficult

    …and an extremely bad idea I must add.

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

Sidebar

Related Questions

Hello I'm working on a problem that requires me to change an set array
@search_results = Array.new duplicates = Set.new results.each { |result| @search_results.push(result) unless duplicates.add?(result[:url]) } This
I have set an array in my config file that I use global in
I have an array set inside a velocity template that contains some paths. The
I got a result set in array format and i want to make square
I cannot figure out how to set an array to one of two sets
Is there any convenient way to take an array/set of objects and create a
For any given NSManagedObject, is there any method to return a set or array
I'm trying to use an array to set the where parameters for a Zend
In Kohana V3 is it possible to return result set as an array() or

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.