我是Android的新手,我正在尝试开发一个显示视频的应用程序,并使用下载管理器下载它 但我有2个问题
1st-当我尝试从我的本地服务器(WAMP服务器)下载视频时,它没有下载,但是如果我从互联网上下载了它的工作
第二次 - 下载箭头没有出现,我不这样做
这是我的下载方法
public void downloadFileFromUrl(String url, String fileName) {
String filePath=Environment.getExternalStorageDirectory() + File.separator + "BlueNet";
try {
Uri downloadUri = Uri.parse("http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4");
//Uri downloadUri = Uri.parse("http://192.168.1.5:8080/BlueNet_NMC/video_share/blue_elephant.mp4");
DownloadManager.Request request = new DownloadManager.Request(downloadUri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
request.setDestinationInExternalPublicDir("/BlueNet",fileName);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
request.setVisibleInDownloadsUi(true);
DownloadManager downloadManager = (DownloadManager)getApplicationContext().getSystemService(DOWNLOAD_SERVICE);
long id= downloadManager.enqueue(request);
Toast.makeText(this, fileName, Toast.LENGTH_LONG).show();
Toast.makeText(this, filePath, Toast.LENGTH_LONG).show();
}
catch (Exception ex){
Toast.makeText(this, ex.toString(), Toast.LENGTH_LONG).show();
}
}
我已将此权限授予我的清单
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
所以请帮忙..