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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:57:41+00:00 2026-05-26T02:57:41+00:00

In the for-loop below the last putExtra overrides the first putExtra even though they

  • 0

In the for-loop below the last putExtra overrides the first putExtra even though they take different parameters and different vars.

First: putExtra(String,String)
Second: putExtra(String, int)

Note: videos[i] is a String array

 Intent intent = new Intent(this,DownloadService.class);
        for(int i=0;i<videos.length;i++){
             intent.putExtra("VIDEOS",videos[i]);
         intent.putExtra("FILENR",(i + 1));          
             startService(intent);

        }

In my DownloadService which extends IntentService the value from VIDEOS is null !!
Why is that ?

EDIT:
This is the part of the code in my DownloadService class:

Intent broadcastIntent = new Intent();
    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, null, 0);

notification = new Notification(R.drawable.icon, "Skitips", System.currentTimeMillis());
contentView = new RemoteViews(getPackageName(), R.layout.progress_layout);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.contentView = contentView;
notification.contentIntent = contentIntent;
contentView.setProgressBar(R.id.status_progress, 100, 0, false);        
contentView.setTextViewText(R.id.status_text,"Downloading...");

String full_url = "";

    full_url = URL + intent.getStringExtra("VIDEOS");

String fileName = "";

    fileName = intent.getStringExtra("VIDEOS");

String fileNr = "";

    fileNr = intent.getStringExtra("FILENR");


    int count;






   Log.e("Whattttttt","is the value of VIDEOOOOSSSS: " + full_url);
    Log.e("Whatttt","is the value of fileNrrrrrrrrrrrr:" + fileNr);
    try {
    URL url = new URL(full_url);
    URLConnection conexion = url.openConnection();
    conexion.connect();
    File file = new File(root.getPath(), fileName);

    int lenghtOfFile = conexion.getContentLength();
    Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

    InputStream input = new BufferedInputStream(url.openStream());
    OutputStream output = new FileOutputStream(file);

    byte data[] = new byte[1024];

    long total = 0;

contentView.setTextViewText(R.id.status_text,”Downloading (” + fileNr + “/77)”);

in the bold text there fileNr i need to get the fileNr from the other activity but it’s giving me null in this case…

  • 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-26T02:57:41+00:00Added an answer on May 26, 2026 at 2:57 am

    In your Question the

    key are always remain same for different values that’s why,,

    try to use

             intent.putExtra(DownloadService.VIDEOS+i,videos[i]);
             intent.putExtra(DownloadService.fileNr+i, i++);     
    

    and get result like,

            DownloadService.VIDEOS0,DownloadService.fileNr0,
            DownloadService.VIDEOS1,DownloadService.fileNr1,
    

    EDIT: try this code..

     Intent intent = new Intent(this,DownloadService.class);
            putStringArrayListExtra("Videos_key", videos);
            startService(intent);
    

    And one more thing if you are passing array of integer and some Array of video URI then please try to use

        putStringArrayListExtra(String name, ArrayList<String> value)
        putIntegerArrayListExtra(String name, ArrayList<Integer> value)
    

    and avoid loop..

    Thanks.

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

Sidebar

Related Questions

In the code below is the initial first loop needed when creating a 2D
Below is a loop that creates six boxes with different colors. When clicking on
I have the below table ID First Name Last Name 1 Ruby Rails 2
I'm having trouble getting the very last draggable item in the loop below to
I'm using a loop as below to render a label and editor for each
I am creating UIButtons inside a loop as shown below. for(int i = 1;
In the below code I'm trying to loop through each child node and append
The code below shows me (I think) that the for each loop is about
How can I loop through the array below and an element per array, with
I have the below but want to only loop through lines in #lines which

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.