I have seen this question several times, but I couldn't find the proper answer. I am trying to open files such as doc, ppt, xls etc. I don't want to open them by downloading, because the file must be read only, and should not be able to be downloaded. The only file that I can open is pdf file. Example: This is what I tried using for opening ppt file. This works only with pdf file when using "application/pdf".
val browserIntent = Intent(Intent.ACTION_VIEW)
browserIntent.setDataAndType(Uri.parse(url), "application/vnd.ms-powerpoint")
val chooser = Intent.createChooser(browserIntent, "Open file")
chooser.flags = Intent.FLAG_ACTIVITY_NEW_TASK // optional
startActivity(chooser)
This is another way of what I tried, example for pdf:
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("https://drive.google.com/viewerng/viewer?embedded=true&url=" + pdf);
Is there any library for opening files or does somebody know another way of opening files. I would be really thankful if you help me :)