i am new with android and i try to create Epub reader.
i already read Epub Files in Android Webview and now i am taring create find functionality
i use this code for find any text in webview it works fine but wane i am go to next page
in my app stile my webview display find items .
code :
int i = webViewRead.findAll(text);
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webViewRead, true);
So, my problem is how to hide the result.
I already try to create new instants of my Webview( and Relode Webview Like webViewRead.reload(); ) but its not work for me.
is any anther way to do it.??
(my content witch i display in webview is xhtml pages).
And one More Thing with this method find text is highlighted with Green color
is their any way to display find text in Red color.
Why not use:
webViewRead.clearMatches();
?
Greg
Related
Case: User should be able to view and print pdf
My solution: I am opening PDF inside Webview with the help of docs.google.com/gview. Below is my code
Set up Webview
string url = "http://www.africau.edu/images/default/sample.pdf";
string gview = $"https://docs.google.com/gview?embedded=true&url={url}";
mWebView.LoadUrl(gview);
Print PDF
var printMgr = (PrintManager)GetSystemService(PrintService);
printMgr.Print("print", mWebView.CreatePrintDocumentAdapter("print"), null);
Below is the screenshot. As you can see PDF loads just fine
Problem
When I want to print PDF, all the PDF pages are printed in one paper which you can see below
I would appreciate any suggestion, including different library for displaying/printing pdf or suggestion in Java or Kotlin, I can convert them to C#.
I would not print the web page but print the PDF directly as when printing the web page it just sees it as a longer web page and knows nothing about the content.
Use a custom print adapter instead, but instead of drawing a PDF to print you can just use the existing PDF you already have.
See for details https://developer.android.com/training/printing/custom-docs.html
I have the URL of a webpage to be displayed into a webview in my Android app. Before showing this page i want to clear the html code of this page from some tag (such as the header, footer, ecc..) in order to show only few information. How can i do it? I tried to solve the issue working with JSoup but i can't understand how to create and pass the "new page" to the webview. Anybody can help me?
EDIT
I cleaned the html code useless through jsoup libraries. Then, always by mean of these, i get head and body content and finally i showing the "cleared" web page through these lines:
headURL = doc.select("head").outerHtml();
bodyURL = doc.select("body").outerHtml();
webview.loadData( "<html>"+headURL+bodyURL+"</html>" , "text/html", "charset=UTF-8");
webview.setWebViewClient(new DisPlayWebPageActivityClient());
The view shows the new page but do not load css files specified in the head(that has not been touched). Who can say me why?
You can fetch the WebPage you want to display as a string, parse and remove whatever you don't want and then load this string as data in your webview.
Something like:
String webContent = fetchPage(url);
String cleanedWebContent = cleanUp(webContent);
webView.loadData(cleanedWebContent, "text/html", "UTF-8");
Of course, you will need to implement fetchPage and cleanUp as they are not Android methods
In my app , I am having a webview . In webview ,I am showing HTML content which is having tag , .I have 2 tabs in that which should switch on clicking on same place. But in webview they are coming one after the other.
In HTML file, I am calling method of Jquery file that method is not getting called . In browser its working fine. In iOS its working.
I am loading webview with base Url method only.
webView.loadDataWithBaseURL(pathToHtml, strLoad, "text/html","UTF-8", "");
These files are in assets . I am not sure that I am able to provide correct path for jquery files. So , I copied files to sdcard. There I am giving path. So path can not be the issue.
Please help me out . I tried many things but nothing worked. I am not getting what is the issue.
You can call a javascript function from webView.loadUrl("javascript:testFunction();"); to change the tabs insted of loading the page again. at the first load, you can use webView.loadUrl("file:///android_asset/index.html"); Befor using the jquery code, make sure that javascript enabled, set the webviewclient and webchromeclient for the webView.
I implemented the the Android webview encounter some problem
Beginning do a OptionMenu, and he will appear when you press the Menu four locations
I use the mouse click taipei he displayed to Toast
But I would like to implement the functionality Toast message screen webview display the specified web page
I use Intent a = new Intent (Intent.ACTION_VIEW, Uri.parse ();
startActivity (a);
Can successfully display the webpage
But I would like to the webview implement web pages using setContentView ();
Switch to taipei.xml <= webview, when I click on the submit button, it could not display the webpage using webview
Please help me to see where the problems lie, because beginners just learning, I hope to try to attach the code to solve my problem.
Code URL: [I implemented the the Android webview encounter some problem
Beginning do a OptionMenu, and he will appear when you press the Menu four locations
I use the mouse click taipei he displayed to Toast
But I would like to implement the functionality Toast message screen webview display the specified web page
I use Intent a = new Intent (Intent.ACTION_VIEW, Uri.parse ("http://www.taipei-101.com.tw/"));
startActivity (a);
Can successfully display the webpage
But I would like to the webview implement web pages using setContentView ();
Switch to taipei.xml <= webview, when I click on the submit button, it could not display the webpage using webview
Please help me to see where the problems lie, because beginners just learning, I hope to try to attach the code to solve my problem.
Code URL: http://www.javaworld.com.tw/jute/post/view?bid=26&id=312960&sty=1#312960
And attach performed on screen picture
And attach performed on screen picture in the cod URL
Implore help thank you
I am trying to open email activity and to display in the email's body the following:
Display a hyperlink to a web site.
Display (not attach) an image logo (.png file).
I tried using html/text/image mime type and nothing works for both things.
I even tried to copy the png file to an sdcard and displaying it from sdcard path instead of using the "Assets" location that may be restricted and private only to the application, but it did not help as well!
Can anyone give me a code which works for both things??
Waiting for you help guys!!
Have you tried :
Linkify.addLinks(yourEmailString, Linkify.WEB_URLS);
yourTextView.setMovementMethod(LinkMovementMethod.getInstance());
It will make all links in the message clickable, not sure if this is what you are searching though :)?