I am working on a app that connects to Raspberry pi device through mobile hot spot and on request it downloads the file from pi device to mobile storage. I have used various methods as suggested on google but no result.currently i am using download manager class , this class works fine on other server like i have tested on local host and web server both but in case of pi server(Apache & CGIHTTP server) it doesn't downloads file.
DownloadManager downloadmanager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri Download_Uri = Uri.parse("http://192.168.43.115/images/cloud.jpg");
System.out.println("DashboardActivity getData() onSuccess Download_Uri :"+Download_Uri);
DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setAllowedOverRoaming(false);
request.setTitle("U4U Downloading " + "Sample" + ".jpg");
request.setDescription("Downloading " + "Sample" + ".jpg");
request.setVisibleInDownloadsUi(true);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/test/" + "/" + "Sample" + ".jpg");
System.out.println("DashboardActivity getData() onSuccess request :"+request);
refid = String.valueOf(downloadmanager.enqueue(request));
System.out.println("DashboardActivity getData() onSuccess refid :"+refid);