Jump to content

Télécharger un fichier


gedeon555

Recommended Posts

Bonjour, est ce qu'il existe une méthode ou un outil pour télécharger un fichier via une url.

Sur certaines applications dont le market, le téléchargement se fait en arrière plan, ne bloque pas l'application est la progression s'affiche dans la zone de notification. L'idéal serait d'avoir ceci.

Link to comment
Share on other sites

pour l'instant j'arrive à télécharger un fichier avec CttpClient, HttpResponse, HttpPost ... Seulement j'ai systématiquement ce message d'erreur dans les logs :

W/SingleClientConnManager( 1002): Invalid use of SingleClientConnManager: connection still allocated.

W/SingleClientConnManager( 1002): Make sure to release the connection before allocating another one.

Link to comment
Share on other sites

  • 1 month later...

gedeon555, t'as trouvé une solution pour éviter :

W/SingleClientConnManager( 1002): Invalid use of SingleClientConnManager: connection still allocated.
W/SingleClientConnManager( 1002): Make sure to release the connection before allocating another one.

?

Edited by neoakira
Link to comment
Share on other sites

  • 8 months later...

J'ai peut être un petit quelque chose qui pourrait vous intéresser...

public Bitmap getImage(String adresse) {
       BitmapFactory.Options bmOptions;
       bmOptions = new BitmapFactory.Options();
       bmOptions.inSampleSize = 1;
       InputStream in = null;
       Bitmap bm = null;
       try {
           URL url = new URL(adresse);
           URLConnection conn = url.openConnection();
           HttpURLConnection httpConn = (HttpURLConnection)conn;
           httpConn.setRequestMethod("GET");
           httpConn.connect();
           if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
               in = httpConn.getInputStream();
           }
           bm = BitmapFactory.decodeStream(in, null, bmOptions);
           in.close();
       } catch (IOException e1) {       }
          return bm;
   }

Sachant que là, c'est pour des Bitmaps... On peut toujours le modifier à sa sauce...

Edit : Woups... J'avais pas vu la date... désolé pour le déterrage... lol

Edited by Kricek
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...