0

hi i was build an app using online free service for my website. this website provide html based app build service .. i know html javascript but dont know android coding . so i need help in this . i want to allow users download image (our designs) when user click on download button image will save on users mobile . can please some help me by provide any html or java code that i will use in my html file .. i hope you understand my question .. here what i try

<a class="WebKitTitle" href="imgurl.com/image.png" data-layout-editable="link" download=""><span data-layout-editable="text">Download This Image</span></a>

in mi3 mobile this work and when i click on download this image .. my download manager will start and save this image into my phone .. but when i try it on other phones this will not work .. please help me thanks ..

deva
  • 91
  • 9
  • Try this link everything is here you are looking for :) http://stackoverflow.com/questions/33434532/android-webview-download-files-like-browsers-do – Lucky Sharma Apr 15 '16 at 10:19
  • You will find it here :) http://stackoverflow.com/questions/33434532/android-webview-download-files-like-browsers-do – Lucky Sharma Apr 15 '16 at 10:20
  • @LuckySharma thanks dear but i dont know about android codes .. and the link you given provide android code .. and i dont no how to use android coding in html files ... any other simple code that i can use in html files . – deva Apr 15 '16 at 10:25
  • @LuckySharma any other help ? – deva Apr 15 '16 at 10:35

1 Answers1

0

are you just making a website for a browser or any hybrid app ?

since it is a hybrid app add a listner to your webview

webView.setDownloadListener(new DownloadListener()
  {
   public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength)
   {
    //for downloading directly through download manager
    Request request = new Request(Uri.parse(url));
    request.allowScanningByMediaScanner();
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "download");
    DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    dm.enqueue(request);
   }
  });

Reference : http://technoranch.blogspot.in/2014/09/downloading-file-from-android-webview.html

Lucky Sharma
  • 173
  • 6
  • hybrid app ... install via google play store ... its not a website like m.mysite.com ... its an app that users download via google app store ... but i was build it with an online free app build service .. and in this you just need to use html and JavaScript .. – deva Apr 15 '16 at 10:44
  • for this you need to add a listner to a webview in android level. webview is a view where you are opening or rendering your html page in android. – Lucky Sharma Apr 15 '16 at 10:48
  • dear , thanks again , but as i describe that i dont know android coding and the site i use is providing me web interface where a app builder help me to build app . just like drag and drop and also i can insert html or javascript code .. but i dont have any option to add android code .. also i dont know how i can put android code in html file .. – deva Apr 15 '16 at 11:09
  • Dear but if you need to open or render any html page in your android view.. you need to open it in a webview, change reqired on html side is the same you have written , code needs to be added on android end – Lucky Sharma Apr 15 '16 at 11:16