0

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);
  • It looks like you are having server misconfiguration. you are using plain http - just sniff the traffic to see what is going on. Also you can use browser with developers tools to diagnose the problem of your server. Also check logs at server. – Maxim Sagaydachny Feb 18 '20 at 07:19
  • @MaximSagaydachny i am only getting the download manager request id in log cat file in android studio. on running the url on server it works and displays the file but on download manager it doesnt work. – Swapnesh Agrawal Feb 18 '20 at 07:41
  • It looks like you have server-side issue. You already tested your client code with different server. Forget about your android app for a minute. Is browser able to download your file from RPI device? – Maxim Sagaydachny Feb 18 '20 at 07:42
  • @MaximSagaydachny yes from browser i am able to do it – Swapnesh Agrawal Feb 18 '20 at 08:28

0 Answers0