-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow MemorizingTrustManager to be called on the UI thread #50
Comments
Sorry, but MTM is always called on the thread of your network connection, and if you do networking on the UI thread, nobody can help you. You should refactor your networking code into a background thread, Service or AsyncTask. |
Not really. See #51 |
I presume you are handling the [onReceivedSslError()](http://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedSslError%28android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError%29) callback? That method provides you with an SslErrorHandler instance that you need to forward the decision to, asynchronously. To allow async usage, either MTM needs to be rewritten, with a blocker thread introduced to handle the existing primary case, or a wrapper Thread needs to be added that can be blocked by MTM and call the correct response handler after the user's decision. Such a wrapper would be very tiny (an anonymous Thread instance should suffice), and it would need to expose some callback API to the application. As you already have a case-specific callback API (SslErrorHandler), you will be writing a thin wrapper around a thin wrapper around a blocking thread. To reduce complexity, it would be easier and more straight-forward to just wrap MTM in a Thread that does call the appropriate SslErrorHandler method after MTM's (blocking) completion. |
This is exactly what I currently do - but at least exposing the Api method for mtm would be great ... |
Currently this will result in an ANR, as wait() is called on the UI thread.
The text was updated successfully, but these errors were encountered: