Skip to content

Instantly share code, notes, and snippets.

@abdul-rehman-2050
Created November 28, 2018 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdul-rehman-2050/b3770796680329071c85bd9c9b0d30a2 to your computer and use it in GitHub Desktop.
Save abdul-rehman-2050/b3770796680329071c85bd9c9b0d30a2 to your computer and use it in GitHub Desktop.
view pdf files in google drive
import android.annotation.SuppressLint
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.webkit.WebView
import android.webkit.WebViewClient
import kotlinx.android.synthetic.main.activity_webview_pdf.*
class WebviewPDFActivity : AppCompatActivity() {
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_webview_pdf)
progress_circular.visibility = View.VISIBLE
webView1.settings.javaScriptEnabled = true
val filename = "http://www3.nd.edu/~cpoellab/teaching/cse40816/android_tutorial.pdf"
// webView1.loadUrl("http://docs.google.com/gview?embedded=true&url=$filename")
webView1.loadUrl("https://drive.google.com/open?id=1GvbQhga7rvMBssBKjIrWiL_Wg2rF7DP1&authuser=0")
webView1.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
// do your stuff here
webView1.visibility = View.VISIBLE
progress_circular.visibility=(View.GONE)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment