Source Code Download File dari URL di Android
Oleh Afa HernandesDiperbarui 1 menit baca

Berikut adalah source Code untuk membuat button download file dari website atau URL menggunakan android Studio :
//public variableDownloadManager downloadManager;String ip="https://androidtonyaray.blogspot.com/"String path="ypathfile/dokumen.pdf";String url=ip+path;
//button onCreateButton btnDownload=(Button)findViewbyid(R.id.btnDownload);btnDownload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { downloadManager = (DownloadManager)getSystemService(Context.DOWNLOAD_SERVICE); Uri uri= Uri.parse(url); DownloadManager.Request request = new DownloadManager.Request(uri); equest.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);Long reference = downloadManager.enqueue(request); Toast.makeText(getBaseContext(), "File berhasil didownload...", Toast.LENGTH_LONG).show();
}});Ngga ada noda ngga belajar


