diff --git a/src/com/upc/pbe/upcnews/Descarrega.java b/src/com/upc/pbe/upcnews/Descarrega.java index 4d0f406..89b1047 100644 --- a/src/com/upc/pbe/upcnews/Descarrega.java +++ b/src/com/upc/pbe/upcnews/Descarrega.java @@ -26,6 +26,7 @@ public class Descarrega extends AsyncTask public void descarregarguardar(String url, String path) throws IOException { + // Descarrega un arxiu i el guarda // Creem l'arxiu File file = new File(path + url.substring(url.lastIndexOf("/")+1, url.length())); @@ -47,6 +48,9 @@ public class Descarrega extends AsyncTask out.flush(); out.close(); in.close(); + + + } protected String doInBackground(String url) throws IOException diff --git a/src/com/upc/pbe/upcnews/MainActivity.java b/src/com/upc/pbe/upcnews/MainActivity.java index 8071d01..a3fb9f0 100644 --- a/src/com/upc/pbe/upcnews/MainActivity.java +++ b/src/com/upc/pbe/upcnews/MainActivity.java @@ -6,10 +6,15 @@ import java.net.MalformedURLException; import java.util.List; import android.app.Activity; +import android.app.DownloadManager; +import android.app.DownloadManager.Request; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.net.Uri; import android.os.Bundle; +import android.os.Environment; import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -42,6 +47,17 @@ public class MainActivity extends Activity implements OnClickListener { if(tempFolder.mkdirs()) { Log.d(TAG,"Directori " + tempFolder.toString() + " creat"); } + + String url = "http://revistes.upc.es/~imanol/PBE/sample_ep_128k-00001.ts"; + Request req = new Request(Uri.parse(url)); + req.setTitle("TestTitle"); + req.setDescription("TestDescription"); + //req.setVisibleInDownloadsUi(false); + req.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "a.ts"); + DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); + manager.enqueue(req); + + //Creem els botons i text URLText = (TextView) findViewById(R.id.textViewUrl); buttonDescarrega = (ImageButton) findViewById(R.id.button);