Is there a way to download over LAN using DownloadManager in android?Is there a way to run Python on Android?How to save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Static way to get 'Context' in Android?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?Download a file with Android, and showing the progress in a ProgressDialogWhat is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?

Examples of hyperbolic groups

Can the Kraus decomposition always be chosen to be a statistical mixture of unitary evolutions?

Which genus do I use for neutral expressions in German?

Write The Shortest Program To Check If A Binary Tree Is Balanced

What is the probability of a biased coin coming up heads given that a liar is claiming that the coin came up heads?

Why do proponents of guns oppose gun competency tests?

Traveling from Germany to other countries by train?

If a vampire drinks blood of a sick human, does the vampire get infected?

Did Captain America make out with his niece?

How many years before enough atoms of your body are replaced to survive the sudden disappearance of the original body’s atoms?

How to switch an 80286 from protected to real mode?

Whats the difference between <processors> and <pipelines> in Sitecore configuration?

How to realistically deal with a shield user?

In MTG, was there ever a five-color deck that worked well?

London underground zone 1-2 train ticket

List: Behavioural characteristics of key Ito processes used in finance

Can you take actions after being healed at 0hp?

How does LIDAR avoid getting confused in an environment being scanned by hundreds of other LIDAR?

Why is the Vasa Museum in Stockholm so Popular?

Definitional equality of two propositions about propositional equality

What are the function of EM and EN spaces?

Does a humanoid possessed by a ghost register as undead to a paladin's Divine Sense?

Our group keeps dying during the Lost Mine of Phandelver campaign. What are we doing wrong?

What was the role of Commodore-West Germany?



Is there a way to download over LAN using DownloadManager in android?


Is there a way to run Python on Android?How to save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Static way to get 'Context' in Android?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?Download a file with Android, and showing the progress in a ProgressDialogWhat is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm developing an app that needs to play a list of videos on an android TV. At first, I play the video by streaming it while also starting a download for the video. When a specific video is already downloaded and it is the one that needs to be played, I use that downloaded video file and play it. On devices (like the tablet that I used for testing) that is using a WIFI connection, the videos are being downloaded. But the TV where I need to run my app is using a LAN connection. Is there a workaround for this problem?



Currently, this is how I start my downloads.



public void startDownload(VideoAd videoAd) 
String videoUrl = videoAd.getUrl();
Uri uri = Uri.parse(videoUrl);

Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
.mkdirs();

lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI


It works. But the problem is it doesn't work on LAN connections.



This is what I currently use in my app.



if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) 
networkArr = connMgr.getAllNetworks();

Log.d(TAG, "networkArr len: "+networkArr.length);
for(Network n : networkArr)
lblNetworks.setText(n.toString()+"n");

else
// Use getAllNetworkInfo()
NetworkInfo[] networkInfArr = connMgr.getAllNetworkInfo();

for(NetworkInfo ni : networkInfArr)
lblNetworks.setText(ni.toString()+"n");




My tablet is running Lollipop and the number I'm getting is 103. I can't try it on the TV because it's on a different building.










share|improve this question
































    2















    I'm developing an app that needs to play a list of videos on an android TV. At first, I play the video by streaming it while also starting a download for the video. When a specific video is already downloaded and it is the one that needs to be played, I use that downloaded video file and play it. On devices (like the tablet that I used for testing) that is using a WIFI connection, the videos are being downloaded. But the TV where I need to run my app is using a LAN connection. Is there a workaround for this problem?



    Currently, this is how I start my downloads.



    public void startDownload(VideoAd videoAd) 
    String videoUrl = videoAd.getUrl();
    Uri uri = Uri.parse(videoUrl);

    Environment
    .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
    .mkdirs();

    lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
    .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI


    It works. But the problem is it doesn't work on LAN connections.



    This is what I currently use in my app.



    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) 
    networkArr = connMgr.getAllNetworks();

    Log.d(TAG, "networkArr len: "+networkArr.length);
    for(Network n : networkArr)
    lblNetworks.setText(n.toString()+"n");

    else
    // Use getAllNetworkInfo()
    NetworkInfo[] networkInfArr = connMgr.getAllNetworkInfo();

    for(NetworkInfo ni : networkInfArr)
    lblNetworks.setText(ni.toString()+"n");




    My tablet is running Lollipop and the number I'm getting is 103. I can't try it on the TV because it's on a different building.










    share|improve this question




























      2












      2








      2








      I'm developing an app that needs to play a list of videos on an android TV. At first, I play the video by streaming it while also starting a download for the video. When a specific video is already downloaded and it is the one that needs to be played, I use that downloaded video file and play it. On devices (like the tablet that I used for testing) that is using a WIFI connection, the videos are being downloaded. But the TV where I need to run my app is using a LAN connection. Is there a workaround for this problem?



      Currently, this is how I start my downloads.



      public void startDownload(VideoAd videoAd) 
      String videoUrl = videoAd.getUrl();
      Uri uri = Uri.parse(videoUrl);

      Environment
      .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
      .mkdirs();

      lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
      .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI


      It works. But the problem is it doesn't work on LAN connections.



      This is what I currently use in my app.



      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) 
      networkArr = connMgr.getAllNetworks();

      Log.d(TAG, "networkArr len: "+networkArr.length);
      for(Network n : networkArr)
      lblNetworks.setText(n.toString()+"n");

      else
      // Use getAllNetworkInfo()
      NetworkInfo[] networkInfArr = connMgr.getAllNetworkInfo();

      for(NetworkInfo ni : networkInfArr)
      lblNetworks.setText(ni.toString()+"n");




      My tablet is running Lollipop and the number I'm getting is 103. I can't try it on the TV because it's on a different building.










      share|improve this question
















      I'm developing an app that needs to play a list of videos on an android TV. At first, I play the video by streaming it while also starting a download for the video. When a specific video is already downloaded and it is the one that needs to be played, I use that downloaded video file and play it. On devices (like the tablet that I used for testing) that is using a WIFI connection, the videos are being downloaded. But the TV where I need to run my app is using a LAN connection. Is there a workaround for this problem?



      Currently, this is how I start my downloads.



      public void startDownload(VideoAd videoAd) 
      String videoUrl = videoAd.getUrl();
      Uri uri = Uri.parse(videoUrl);

      Environment
      .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
      .mkdirs();

      lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
      .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI


      It works. But the problem is it doesn't work on LAN connections.



      This is what I currently use in my app.



      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) 
      networkArr = connMgr.getAllNetworks();

      Log.d(TAG, "networkArr len: "+networkArr.length);
      for(Network n : networkArr)
      lblNetworks.setText(n.toString()+"n");

      else
      // Use getAllNetworkInfo()
      NetworkInfo[] networkInfArr = connMgr.getAllNetworkInfo();

      for(NetworkInfo ni : networkInfArr)
      lblNetworks.setText(ni.toString()+"n");




      My tablet is running Lollipop and the number I'm getting is 103. I can't try it on the TV because it's on a different building.







      android android-5.0-lollipop lan android-download-manager






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 30 at 6:32







      rminaj

















      asked Mar 27 at 3:50









      rminajrminaj

      5510 bronze badges




      5510 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1














          One potential solution is to get the network you want and bind your process to this network via connectivity manager. See bindProcessToNetwork. You can get the network needed via getAllNetworks() iterate over them and check if the network info matches the network info you would like.






          share|improve this answer

























          • Hi. I tried your solution but what I only get is a number with 3 digits. Is that correct?

            – rminaj
            Mar 27 at 8:52











          • Can you elaborate? when do you get 3 digits? Maybe post the code?

            – Mohamed Abdalkader
            Mar 27 at 17:06











          • Hi, please check my update.

            – rminaj
            Mar 28 at 8:32


















          1














          For TV, 'NETWORK_MOBILE' wont work. I would suggest to remove it and try with below mentioned code:-



          lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
          .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
          .setTitle("Downloading video ad")
          .setDescription("Downloading "+getVideoNameFromLink(videoUrl))
          .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, getVideoNameFromLink(videoUrl)));


          If this code works for TV, you need to apply a check(if it is TV) and handle code accordingly.






          share|improve this answer

























          • Well, I just used what I found before. Thanks. And our android TV are not really a real android TV but I have a way to do the checking.

            – rminaj
            Mar 27 at 7:02














          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55369512%2fis-there-a-way-to-download-over-lan-using-downloadmanager-in-android%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          One potential solution is to get the network you want and bind your process to this network via connectivity manager. See bindProcessToNetwork. You can get the network needed via getAllNetworks() iterate over them and check if the network info matches the network info you would like.






          share|improve this answer

























          • Hi. I tried your solution but what I only get is a number with 3 digits. Is that correct?

            – rminaj
            Mar 27 at 8:52











          • Can you elaborate? when do you get 3 digits? Maybe post the code?

            – Mohamed Abdalkader
            Mar 27 at 17:06











          • Hi, please check my update.

            – rminaj
            Mar 28 at 8:32















          1














          One potential solution is to get the network you want and bind your process to this network via connectivity manager. See bindProcessToNetwork. You can get the network needed via getAllNetworks() iterate over them and check if the network info matches the network info you would like.






          share|improve this answer

























          • Hi. I tried your solution but what I only get is a number with 3 digits. Is that correct?

            – rminaj
            Mar 27 at 8:52











          • Can you elaborate? when do you get 3 digits? Maybe post the code?

            – Mohamed Abdalkader
            Mar 27 at 17:06











          • Hi, please check my update.

            – rminaj
            Mar 28 at 8:32













          1












          1








          1







          One potential solution is to get the network you want and bind your process to this network via connectivity manager. See bindProcessToNetwork. You can get the network needed via getAllNetworks() iterate over them and check if the network info matches the network info you would like.






          share|improve this answer













          One potential solution is to get the network you want and bind your process to this network via connectivity manager. See bindProcessToNetwork. You can get the network needed via getAllNetworks() iterate over them and check if the network info matches the network info you would like.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 4:10









          Mohamed AbdalkaderMohamed Abdalkader

          2511 gold badge3 silver badges6 bronze badges




          2511 gold badge3 silver badges6 bronze badges















          • Hi. I tried your solution but what I only get is a number with 3 digits. Is that correct?

            – rminaj
            Mar 27 at 8:52











          • Can you elaborate? when do you get 3 digits? Maybe post the code?

            – Mohamed Abdalkader
            Mar 27 at 17:06











          • Hi, please check my update.

            – rminaj
            Mar 28 at 8:32

















          • Hi. I tried your solution but what I only get is a number with 3 digits. Is that correct?

            – rminaj
            Mar 27 at 8:52











          • Can you elaborate? when do you get 3 digits? Maybe post the code?

            – Mohamed Abdalkader
            Mar 27 at 17:06











          • Hi, please check my update.

            – rminaj
            Mar 28 at 8:32
















          Hi. I tried your solution but what I only get is a number with 3 digits. Is that correct?

          – rminaj
          Mar 27 at 8:52





          Hi. I tried your solution but what I only get is a number with 3 digits. Is that correct?

          – rminaj
          Mar 27 at 8:52













          Can you elaborate? when do you get 3 digits? Maybe post the code?

          – Mohamed Abdalkader
          Mar 27 at 17:06





          Can you elaborate? when do you get 3 digits? Maybe post the code?

          – Mohamed Abdalkader
          Mar 27 at 17:06













          Hi, please check my update.

          – rminaj
          Mar 28 at 8:32





          Hi, please check my update.

          – rminaj
          Mar 28 at 8:32













          1














          For TV, 'NETWORK_MOBILE' wont work. I would suggest to remove it and try with below mentioned code:-



          lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
          .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
          .setTitle("Downloading video ad")
          .setDescription("Downloading "+getVideoNameFromLink(videoUrl))
          .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, getVideoNameFromLink(videoUrl)));


          If this code works for TV, you need to apply a check(if it is TV) and handle code accordingly.






          share|improve this answer

























          • Well, I just used what I found before. Thanks. And our android TV are not really a real android TV but I have a way to do the checking.

            – rminaj
            Mar 27 at 7:02
















          1














          For TV, 'NETWORK_MOBILE' wont work. I would suggest to remove it and try with below mentioned code:-



          lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
          .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
          .setTitle("Downloading video ad")
          .setDescription("Downloading "+getVideoNameFromLink(videoUrl))
          .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, getVideoNameFromLink(videoUrl)));


          If this code works for TV, you need to apply a check(if it is TV) and handle code accordingly.






          share|improve this answer

























          • Well, I just used what I found before. Thanks. And our android TV are not really a real android TV but I have a way to do the checking.

            – rminaj
            Mar 27 at 7:02














          1












          1








          1







          For TV, 'NETWORK_MOBILE' wont work. I would suggest to remove it and try with below mentioned code:-



          lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
          .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
          .setTitle("Downloading video ad")
          .setDescription("Downloading "+getVideoNameFromLink(videoUrl))
          .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, getVideoNameFromLink(videoUrl)));


          If this code works for TV, you need to apply a check(if it is TV) and handle code accordingly.






          share|improve this answer













          For TV, 'NETWORK_MOBILE' wont work. I would suggest to remove it and try with below mentioned code:-



          lastDownload = dlMgr.enqueue(new DownloadManager.Request(uri)
          .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
          .setTitle("Downloading video ad")
          .setDescription("Downloading "+getVideoNameFromLink(videoUrl))
          .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, getVideoNameFromLink(videoUrl)));


          If this code works for TV, you need to apply a check(if it is TV) and handle code accordingly.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 4:45









          JatinJatin

          3381 silver badge10 bronze badges




          3381 silver badge10 bronze badges















          • Well, I just used what I found before. Thanks. And our android TV are not really a real android TV but I have a way to do the checking.

            – rminaj
            Mar 27 at 7:02


















          • Well, I just used what I found before. Thanks. And our android TV are not really a real android TV but I have a way to do the checking.

            – rminaj
            Mar 27 at 7:02

















          Well, I just used what I found before. Thanks. And our android TV are not really a real android TV but I have a way to do the checking.

          – rminaj
          Mar 27 at 7:02






          Well, I just used what I found before. Thanks. And our android TV are not really a real android TV but I have a way to do the checking.

          – rminaj
          Mar 27 at 7:02


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55369512%2fis-there-a-way-to-download-over-lan-using-downloadmanager-in-android%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript