簡體   English   中英

下載Mp3文件(Android)

[英]Download Mp3 Files (Android)

我讓Application從Internet播放一些mp3文件,並且我想添加“下載按鈕”以從Internet下載我想從瀏覽器下載的任何mp3文件,而不是從Application,但是如果我要調用瀏覽器,例如:


startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(“ xxxx.xxxx.xxxx.mp3”)));;


瀏覽器將播放此mp3文件:(

我想我可以在鏈接后添加東西以直接下載,,,任何人都可以幫助我嗎?

注意:如果您有要從App下載的代碼,請告訴我有關的信息:)我是android world的新手:P,並且我希望有一個簡單的代碼可以理解它,謝謝大家:)

使用DownloadManager會更好。 您可以在此處查看Lars Vogel的示例代碼

相關位:

DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        Request request = new Request(
                Uri.parse("http://www.vogella.de/img/lars/LarsVogelArticle7.png"));
        enqueue = dm.enqueue(request);

請注意,DownloadManager在API版本9(Android 2.3,Gingerbread)及更高版本上可用。

您可以將其放在您的download.php文件中

 <?php
     $file = $_GET['file'];
     header ("Content-type: octet/stream");
     header ("Content-disposition: attachment; filename=".$file.";");
     header("Content-Length: ".filesize($file));
     readfile($file);
     exit;
   ?>

接着:

 Uri.parse("direct_download.php?file=filename.mp3");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM