GithubHelp home page GithubHelp logo

android-asynctask-download-image-example's Introduction

Android-AsyncTask-Download-Image-Example

This code is based on the YouTube video Android Studio Tutorial - 67 - Download Image Using AsyncTask by Prabeesh R K. There are a few changes in particular this line is used in place of the hardcoded "sdcard/photoalbum"

File new_folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "myfolder");

In particular this code works with JellyBean Android API 18. It will not work with Marshmallow and later because of the new runtime permissions. I will post a version that does do this shortly.

The emulator for Jellybean Android v18 did NOT work with this code when run from Android Studio. The emulator did not work with the internet. I was not able to using the browser on the phone to surf the internet and so the AVD would timeout when trying to download the image. I had to start the emulator from the command line using my particular dns server as follows...

wherever-your-android-sdk-is-located/tools/emulator.exe -avd Nexus_5_API_18 -dns-server xxx.xxx.xxx.xxx

...where Nexus_5_API_18 is the name of your AVD file and xxx.xxx.xxx.xxx is the IP address of your domain name server. Doing this the internet on the emulator was able to work.

You can browse the filesystem of your emulator using Android Studio -> Tools -> Android -> Android Device Monitor. Here you can see that the URI "sdcard" is a link to another storage folder where you will be able to see your image that has been downloaded.

It is possible to download a file manager by dragging and a dropping an APK onto your emulator. Here is one ES File Manager use at your discretion - I cannot vouch for this software.

Hope this proves useful.

android-asynctask-download-image-example's People

Contributors

grantmarch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.