When loading "https" url in android web view, getting connection timeout error - android-webview

When i am trying to load https url it results a blank page. I overrided onReceivedSslError method in webviewclient but this overrided method is never executing. Also I overrided onReceivedError method in which i am getting CONNECTION_TIMED_OUT as error description argument.
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
super.onReceivedSslError(view, handler, error);
handler.proceed();
}
#Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// TODO Auto-generated method stub
super.onReceivedError(view, errorCode, description, failingUrl);
Toast.makeText(getApplicationContext(), description, 200).show();
}

Related

How to capture mouse click events from console in eclipse plugin

I'm developing an eclipse plugin. It writes some lines in a console. In order to select a line displayed in the console, I’m trying to capture mouse double click event from that console.
The console has been implemented by following this eclipse FAQ. MessageConsole or IconsoleView classes doesn‘t seem to provide a methode to add a listener with an SWT.MouseDoubleClick event.
Is there any way to capture a mouse event from a console and then read the selected line ?
The MessageConsole doesn't know anything about how the data is displayed, it is the TextConsoleViewer that deals with that.
To access the console viewer you need to use a custom message console - extending MessageConsole or TextConsole and overriding createPage to create your own console page extending TextConsolePage.
The console page needs to override the createViewer method to create your own text console viewer extending TextConsoleViewer.
In the viewer you can override the mouseDoubleClick method to receive the double clicks.
For an example see the Eclipse JDT JavaStackTraceConsole, JavaStackTraceConsolePage, and JavaStackTraceConsoleViewer classes.
public class JavaStackTraceConsole extends TextConsole {
...
#Override
public IPageBookViewPage createPage(IConsoleView view) {
return new JavaStackTraceConsolePage(this, view);
}
}
public class JavaStackTraceConsolePage extends TextConsolePage {
...
#Override
protected TextConsoleViewer createViewer(Composite parent) {
return new JavaStackTraceConsoleViewer(parent, (JavaStackTraceConsole) getConsole());
}
}
public class JavaStackTraceConsoleViewer extends TextConsoleViewer {
...
}
Thank you, it works fine. I just had to managed the mouse event in another way because overriding the mouseDoubleClick method didn’t work. Here is my code :
public class MyTextConsoleViewer extends TextConsoleViewer {
public MyTextConsoleViewer(Composite parent, MyMessageConsole console) {
super(parent, console);
StyledText styledText = getTextWidget();
MouseListener listener = new MouseListener() {
#Override
public void mouseUp(MouseEvent arg0) {
// TODO Auto-generated method stub
}
#Override
public void mouseDown(MouseEvent arg0) {
// TODO Auto-generated method stub
}
#Override
public void mouseDoubleClick(MouseEvent event) {
// TODO Auto-generated method stub
IDocument document = console.getDocument();
try {
int currentLine = document.getLineOfOffset(styledText.getOffsetAtLocation(new Point (event.x, event.y)));
IRegion lineInfo = document.getLineInformation(currentLine);
System.out.println(document.get(lineInfo.getOffset(), lineInfo.getLength()));
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
styledText.addMouseListener(listener );
// TODO Auto-generated constructor stub
}
public MyTextConsoleViewer(Composite parent, TextConsole console,
IScrollLockStateProvider scrollLockStateProvider) {
super(parent, console, scrollLockStateProvider);
// TODO Auto-generated constructor stub
}
#Override
public void mouseDoubleClick(MouseEvent e) {
System.out.println("This even doesn't work!");
}
}

Loading Resty-GWT

How can I show load widget, when client send json on server.
From example in GWTP exmaple I found such method
/**
* We display a short lock message whenever navigation is in progress.
*
* #param event The {#link LockInteractionEvent}.
*/
#ProxyEvent
public void onLockInteraction(LockInteractionEvent event) {
getView().setLoading(event.shouldLock());
}
How do I show in the loading resty-gwt, when it sent the request? Can I use onLockInteraction with resty-gwt?
You can use RestyGWT custom Dispatcher to track request lifecycle. Dispatcher can be configured manually or using annotations (https://resty-gwt.github.io/documentation/restygwt-user-guide.html). Example setting it manually:
RootRestService rest = GWT.create(RootRestService.class);
((RestServiceProxy) rest).setDispatcher(new DefaultDispatcher() {
#Override public Request send(Method m, RequestBuilder rb) throws RequestException {
RequestCallback callback = rb.getCallback();
rb.setCallback(new RequestCallback() {
#Override public void onResponseReceived(Request req, Response res) {
log.info("request success (stop event)");
callback.onResponseReceived(req, res);
}
#Override public void onError(Request req, Throwable ex) {
log.info("request error (stop event)");
callback.onError(req, ex);
}
});
try {
log.info("request initialized (start event)");
return request = super.send(m, rb);
} finally {
log.info("request fail to initialize error (stop event)");
}
}
});
Instead of logging, you can send an event using the eventBus, and use this event to keep track of the number of active request, and finally show a loading indicator if the number of active request is grater than 0.

Android load url in internal WebView issue

I have a problem with a specific site when loading in my apps internal webview.
In the LogCat i get these 2 lines (the tag is "chromium").
[INFO:CONSOLE(25)] "Uncaught TypeError: Cannot call method 'getItem' of null", source: http://m.ynet.co.il/Default_Ynet.aspx?type=3&id=4519238 (25)
[INFO:CONSOLE(73)] "Uncaught TypeError: Cannot call method 'push' of undefined", source: http://m.ynet.co.il/Default_Ynet.aspx?type=3&id=4519238 (73)
If i redirect to the external browser all is fine. Also it happens only with the above site (see in logcat)
public class WebActivity extends Activity {
WebView wv;
final Activity activity = this;
#SuppressLint("SetJavaScriptEnabled")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
setContentView(R.layout.activity_web);
wv = (WebView)findViewById(R.id.webView1);
Intent intent = getIntent();
final String url = intent.getStringExtra("url");
Log.i("webView", url);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if(progress == 100)
activity.setTitle(R.string.app_name);
}
});
wv.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
wv.loadUrl(url);
}
Any ideas?
It turns out that there was a problem using the shouldOverrideUrlLoading method (below) with this particular site.
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
Once this was deleted all was good...

Page is not being loaded in GWT

I am using activities and places to develop my application. When I click on the link on the left, my page is loaded, and I put the values in the fields. After I put the values, I send a RPC to the server, and get response back. This is also shown. Now the problem is that even if I click on the link on the left, I am getting the result page again. I am not getting the input page.
Impl code
#UiHandler("entInvoiceCompare")
void onClickSubmit(ClickEvent e) {
GWT.log("Going to enterprise compare place");
//listener.goTo(new EnterpriseInvoiceCompareViewPlace());
NewEBRM.getClientFactory().getPlaceController().goTo(new EnterpriseInvoiceCompareViewPlace());
}
Place
public class EnterpriseInvoiceCompareViewPlace extends Place{
public EnterpriseInvoiceCompareViewPlace() {
GWT.log("EnterpriseInvoiceCompareViewPlace: constructor");
}
public static class Tokenizer implements PlaceTokenizer<EnterpriseInvoiceCompareViewPlace> {
#Override
public String getToken(EnterpriseInvoiceCompareViewPlace place {
GWT.log("EnterpriseInvoiceCompareViewPlace: getToken: call");
return "EntInvoiceCompare";
}
#Override
public EnterpriseInvoiceCompareViewPlace getPlace(String token) {
GWT.log("EnterpriseInvoiceCompareViewPlace: getPlace: call");
return new EnterpriseInvoiceCompareViewPlace();
}
}
}
Activity
#Override
public void start(AcceptsOneWidget containerWidget, EventBus eventBus) {
// TODO Auto-generated method stub
GWT.log("EnterpriseInvoiceCompareActivity: start: starting activity");
EnterpriseInvoiceCompareView entInvoiceCompareView = clientFactory.getEnterpriseInvoiceCompareView();
entInvoiceCompareView.setPresenter(this);
containerWidget.setWidget(entInvoiceCompareView.asWidget());
GWT.log("EnterpriseInvoiceCompareActivity: start: ending activity");
}

GWT MVP - retriving custom event parameters problem

I am developing a GWT application with presenter, dispatcher and Gin.
I have a presenter which is retrieving an ArrayList<JobPosting> from
server and firing a ManageJobsEvent.
dispatcher.execute(new GetJobPostings(userId), new
DisplayCallback<GetJobPostingsResult>(display) {
#Override
protected void handleFailure(Throwable e) {
e.printStackTrace();
Window.alert(SERVER_ERROR);
}
#Override
protected void handleSuccess(GetJobPostingsResult value) {
eventBus.fireEvent(new ManageJobsEvent(value.getUserId(),
value.getJobPostings()));
}
});
I get the callback to onPlaceRequest(PlaceRequest request) of my
another presenter
but how do i get the ArrayList<JobPostings> set in the event.
I'm not sure I understand your problem correctly, but since you are passing the ArrayList<JobPostings> to the constructor of the ManageJobsEvent, why not just add a getter to retrieve it?