Created
November 28, 2018 19:53
-
-
Save abdul-rehman-2050/b3770796680329071c85bd9c9b0d30a2 to your computer and use it in GitHub Desktop.
view pdf files in google drive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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