Highlight a specific text in WebView android 4.0 - android

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

Related

Crosswalk (xwalk) pull to refresh not working

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.

how to clear a text edit field? android python appium

how to clear text edit field? android python appium?
I tried that way:
el = driver.find_element_by_id('text edit field id').clear()
el.click()
el.clear()
however, it actually deletes only one symbol.
I think may by call an el.click() twice and send keycode to delete highlighted text area but how to highlight the text?
Interestingly, such problem reproduces in Sony Xperia z3 compact, android 5.0.1.
In lg, nexus android 4.4,5.1 accordingly, the above code works well
i had faced same issue with my android application but i am doing automation in java , so for the solution i am performing tap Action twice near the location of the element so it will select all the text which already written in text field and after that click on that "cut" symbol so it will clear text field.
i have written a method for sendkeys in android device.
public void typeForAndroid(AppiumDriver appiumDriver,WebElement ele,String text)
{
if(ele.getText().isEmpty())
{
ele.sendKeys(text);
}
else
{
TouchAction action=new TouchAction(appiumDriver);
action.tap(ele.getLocation().getX()+5, ele.getLocation().getY()+5);
action.tap(ele.getLocation().getX()+5, ele.getLocation().getY()+5);
appiumDriver.performTouchAction(action);
pause(2);
try{
appiumDriver.findElementById("android:id/cut").click();
}
catch(Exception e)
{
appiumDriver.sendKeyEvent(67);
}
pause(2);
ele.sendKeys(text);
}
}
this is working for me. I hope this might works for you.
in this i have used appiumdriver but you can also use androiddriver.
Thanks

How to hide error message after right value selected from select box in jQuery.validationEngine along jquery mobile?

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"});
});

Findall / FindAllAsync not working properly on android 4.1 jelly bean

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.

Android:cannot make a selection after WebView search with highlight

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;

Categories

Resources