PDF не загружается в WebView - PullRequest
0 голосов
/ 18 ноября 2018

У меня есть проект, который должен печатать файл PDF.Но всякий раз, когда я нажимаю кнопку Печать квитанции , она ничего не загружает.В чем проблема?

public class MainActivity extends AppCompatActivity {

public WebView mywebview;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mywebview=(WebView)findViewById(R.id.webview);
    WebSettings webSettings=mywebview.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mywebview.loadUrl("Some URL");

    mywebview.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent,
                                    String contentDisposition, String mimetype,
                                    long contentLength) {
            DownloadManager.Request request = new DownloadManager.Request(
                    Uri.parse(url));

            request.allowScanningByMediaScanner();
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed!
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "Name of your downloadble file goes here, example: Mathematics II ");
            DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
            dm.enqueue(request);
            Toast.makeText(getApplicationContext(), "Downloading File", //To notify the Client that the file is being downloaded
                    Toast.LENGTH_LONG).show();

        }
    });
    //Code for Opening the app
    mywebview.setWebViewClient(new WebViewClient());

}

//Code for Back button


}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...