I have a small android app that haves a webview. In android 2.2, 2.3, I can perform a search on this webview using findAll and it works great, highlights the words being searched and scrolls to the position of the match.
In android 4.0.X, the search works and scrolls ok, but no highlight (using findAll).
In android 4.1, using findAll or findAllAsync, it doesn't really matter, the search doesn't work well at all. In my tests, it performs the search, but does not scroll to the position of the match, instead returning to the top of the page, which is ridiculous. It even highlights the match, but without going to the position on the webview it's as good as useless from a usability standpoint.
Here's the source codes:
//////////////////////////////
// for android 2.2, 2.3, 4.0.x
//////////////////////////////
myContent.findAll(findBox.getText().toString());
try{
//Can't use getMethod() in android 4.0.3 as it's a private method
for(Method m : WebView.class.getDeclaredMethods()){
if(m.getName().equals("setFindIsUp")){
m.setAccessible(true);
m.invoke(myContent, true);
break;
}
}
}catch(Exception ignored){}
Then, on another method with target api 16:
/////////////////////////////
// for android 4.1
/////////////////////////////
myContent.findAllAsync(findBox.getText().toString());
try{
//Can't use getMethod() in android 4.0.3 as it's a private method
for(Method m : WebView.class.getDeclaredMethods()){
if(m.getName().equals("setFindIsUp")){
m.setAccessible(true);
m.invoke(myContent, true);
break;
}
}
}catch(Exception ignored){}
Any ideas on how to make the search work on jelly bean? Thank you very much.
Related
I'm using Crosswalk (XwalkView) instead of the default Webview on Android but it seems that the defalt pull-to-refresh functionality doesn't work on Android 4.3. I've tested it on 5.0 and it's ok, but on 4.3 and 4.2.2 it doesn't work. I'm guessing it has to do with < 5.0 ?!
I've tried something like this to enable it, but it failed to work:
//Disable the edge effect and try to enable pull to refresh in case we're using xwalk webviews
if (BuildConfig.IS_XWALK) {
final String INIT_SWITCHES[] = {"Xwalk", "--enable-pull-to-refresh-effect", "--disable-overscroll-edge-effect"};
if (!CommandLine.isInitialized()) {
CommandLine.init(INIT_SWITCHES);
}
}
Any ideas ?
Actually, we already have a JIRA about this feature, please track it here: https://crosswalk-project.org/jira/browse/XWALK-6277.
It has some block issue before, but we will continue investigating how to implement it.
I have developed an application using SAPUI5. The spinner has to appear when navigating from one page to other. The spinner works fine on jelly bean android version. But fails on higher versions. Can anyone help me with this?
sap.ui.getCore().byId('loadingIndicator').setText("Loading...");
sap.ui.getCore().byId('loadingIndicator').open();
use sap.m.BusyDialog
var oBusyDialog = new sap.m.BusyDialog();
oBusyDialog.open();// will work when DOMis already there
oBusyDialog.close();//else it throws error and page completely fails in IE.
hence put it in try catch
try{
oBusyDialog.open();
}catch(e){
//Error handler
console.log("Busy dialog couldn't be loaded:"+e);
}
Check Preview here
Note: On Page refresh, DOM will not loaded before you call open() or
close() method, hence put it in try catch.
I am using jQuery validationEngine with jQuery mobile plugin in my mobile page, am validating the dropdown list if it has empty value once I set proper value the error message is not getting in hide samsung galaxy android phones but same is working fine in sony xperia and also in normal web browser(PC), can somebody help to fix this ..
specifications,
jQuery Validation Engine 2.2, jquery-1.8.1.min, jquery.mobile-1.1.1.min,
along with symfony 1.1
The above is working fine in Android 4.0 but not working in android
2.2 and 2.3
Thanks in advance,
Finally I got solution for the my problem...
I override the validationEngine method on those fields on change of the select box,
$('#day').change(function(){
if( $(this).val()!= '日'){
$("#day").validationEngine('hide');
}
else {
$("#day").validationEngine('showPrompt', '* 半角数字でご入力して下さい。', 'red',"topLeft",true);
}
$("#confirm").validationEngine('detach');
$("#confirm").validationEngine('attach',{promptPosition : "topLeft"});
});
I want to highlight a specific (searching) text on WebView. I use the code
myWebView.findAll(txtSearch);
try {
for (Method m : WebView.class.getDeclaredMethods()) {
if (m.getName().equals("setFindIsUp")) {
m.setAccessible(true);
m.invoke(myWebView, true);
break;
}
}
} catch (Exception ignored) {
}
This works great on Android 2.2, but it doesn't work on Android 4.0 and above
Yes, you are right, highlight text on WebView works great on Android 2.2, but he appeared as not working on Android 4.0 and above
look at this link
here
i am also trying this highlight of text ,it is working perfectly on
android version 2.2 but if i am trying the same thing in another
version than the highlight text is not shown and one more thing that
findasync() only works for api 16 .May be using java script can help i
am working on that if it works i'll tell to you.
thanks
Hello I have a bug in my app and I cannot figure it out.
I want to search for text in my WebView and get the found Text highlighted
for Android 1.5-2.3 this works quite well
public void onClick(View v){
webView1.findNext(true);
int i = webView1.findAll(findBox.getText().toString());
try{
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webView1, true);
}catch(Exception ignored){}
}
}
for Android 3.0+ I have to use the JavaScript workaround from here, because Google doesn't support the highlighting of searched text for incomprehensible reasons
And now my Bug: After the search on my WebView I get the highlighted Text, and I can't select the Text anymore. The only fix I could use is the JavaScript workaround in older Android versions, too. But the function runs very slow and it takes about 10 seconds until the text gets highlighted. I Hope someone has a better solution/fix :)
Thank you
I use the same for 3.x then it did not work on 4.0.x.
Yesterday I updated to 4.0.4 and now highlight works again.
So the solution can be found in the 4.0.4 sources.
OK I have found a quite good solution.
Here is a JavaScript code for Highlighting, that runs really fast :) http://4umi.com/web/javascript/hilite.php#thescript
Anyway I don't understand, why I can't selecting text after the of the official Webview search
For Android 3.x I used webview.showFindDialog(stringtofind, true);
use findAllAsync() instead , finAll() is deprecated in API 16;