display html in popup - java

What we do is we define a webview and make the html files being displayed in that. Is it possible to display an html file in android's default pop up on the same screen? I have stored the html file in assets/www folder.
Please let me know regarding this

It is possible to display a WebView or any other UI in a default Android Dialog. But, it is better and easier for you to make your own custom Dialog class and display the WebView in that. You can also make it an Activity and use the Dialog theme to make the Activity look and behave like a Dialog.
You are correct to put your .html file in the "assets" folder. That is what I do.
Load the WebView like this:
private final static String url = "file:///android_asset/file.html";
webview.loadUrl(baseUrl);

Related

Java, servlet access restriction

I work on a Java project with Echo Studio 3.
I have a servlet that display a Pdf file.
I call this servlet with a button that open a new window with this code:
Command open = new BrowserOpenWindowCommand("http://localhost:8080/MyApp/app/DisplayFile", "_blank");
Application.getActive().enqueueCommand(open);
I would like to allow the access to this servlet only to users who clicked on this button, but I don't know how to handle this.
Any idea?
Pass an additional parameter in the link to identify the click.
Or else capture the click event in javascript and add additional parameter to the server url to inform that the button has been pressed.

Gather text-data from html file

I'm making an app which will display quite a lot of information in text. I would love to be able to change this text without having to do any updates to the app itself and there-fore it would be great to just get the text from a simple HTMl-file from a server and display it in a textview. Is this possible?
TL;DR: Is there a way to display text from a remote HTML-file in a textview?
-Alexander
Your app can send a request to get your HTML page and then set the value of a TextView to be the content of the page as shown in this example: https://developer.android.com/training/volley/simple.html

Call HTML page with javascript content

I am stuck at an issue, I don't know if its possible or not.
I need to call a HTML page, but the page has some content being loaded via Javascript too and I need to get that also.
Is this some how possible ?
Currently I have used plain: new URL(url).openConnection() and it's not returning that.
Any Help ?
Thanks
To do that you'll need to host a WebView in your application. It can be hidden if you want. Call the webview loadUrl to load the content you want. Handle the WebViewClient onPageFinished so you know all of the content has loaded, and then use the javascript bridge interface (addJavascriptInterface) to pass the HTML back up to the application.

SWT browser view page source

I am using SWT browser in my application
I have edited SWT source code according to my need, Now I want a feature of view web page source code by click on button
I have managed "Go to Home page " like this
public void goHome() {
int[] rgdispid = auto.getIDsOfNames(new String[]{"GoHome"});
int dispIdMember = rgdispid[0];
auto.invoke(dispIdMember);
}
I want to know if there is any string for "view page source" like "GoHome"
Or is there any other way to do this.
Thanks in advance
Based on the API of the SWT Browser, looks like you can get the HTML of the page by calling the getText() method.
Eclipse SWT Browser API

How do I get a file's icon in Java?

I'm making a basic file browser and wish to display the icon of each file. Is there any way to get this?
Icon icon = FileSystemView.getFileSystemView().getSystemIcon( File );

Categories