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
Related
I am making an app for tracking courier. the user will enter tracking no.in apps textview and click submit this will open couriers website tracking page i.e fedex in a webview inside the App.
Now i want a way to pass those tracking no from my app to webview's website input field and click the submit button on the website automatically
I don't think this the way you should do that, you should look for a url that takes the tracking location number as a query and return the proper page
something like that http://example.com/over/there?number=441222
Update
I've looked at the page you've mentioned in the comments and all I can get is that it submits a post request as a form input
POST url: https://www.myutiitsl.com/PAN_ONLINE/PANTrackerSearch.action
parameter names are
appNo
panNo
I wish I had more knowledge as a web developer but this the way that could work with you try to make sure the post url is correct and the parameters I mentioned also correct and it should work with you
I want to count banner impressions in my web page. For Example I have a image slider and I need to count how many times each image displayed in my page, And each individual image count should have to save in the database.
I want write this in java or javascript
Can anyone Help me please.
Thanks
How about
$(function(){
$('img').load(function(){
$.post('update.php', {img: $(this).attr("id")});
});
});
And in update.php you will get a post request with $_POST['img'] = Image-Id. Use it to update the count record in your database with +1.
Keep in mind this will create a new request to update.php for each image that is loaded.
PS: You need jQuery.
I create pdf using Velocity template, but i am not able to put images in pdf.
I am adding url into context object and accessing that object into eot.vm file, url is going proper but still images are not displaying in pdf.
Thanks & Regards,
Tushar
Make sure that URL you are passing is sending IMAGE as response not an full html page.
i was passing URL that was sending me a whole html page, so i was unable to see images.
But now its fixed.
Please visit below link:
https://answers.atlassian.com/questions/2907/how-to-access-image-generated-via-velocity-template-confluence
The problem I'm having is the following:
I have an app with two separate modes: A WebView for browsing and a custom Canvas. The custom Canvas captures handwriting samples for language placement exams. Here's how it works. A user logs in to Moodle via the WebView. After they log in, they navigate to a Quiz inside Moodle. They click a link on one of the Quiz's questions and this launches an Intent which hides the WebView and shows the Canvas. The user then writes (using a stylus) on the Canvas. When a user is finished writing their essay (or whatever), they press a button that uploads an image file to Moodle. I am able to upload images to a point, it's getting them to show up in the HTML page that the user clicked the link in originally (see above) and to get Moodle to commit them to permanent storage that is the problem. Normally this is all accomplished through AJAX (really AJAJ since it's JavaScript and JSON) and when the user drops a file on this one component, the component refreshes and uploads the file.
Here is the problem: I need the WebView so that students can log in to Moodle through Shibboleth. But because the underlying JavaScript in the browser makes AJAX calls to the Moodle server and since the Java side of Android doesn't have access to the DOM, I have use the Apache HTTP components library to make some of the connections below basically to preserve the state of the HTML page in WebView.
In a desktop browser on, say, Windows, I use WebScarab to monitor the browser's requests and this is what I see: the browser uploads a file to Moodle via five successive calls to the following scripts:
POST https://[moodle website]/repository/repository_ajax.php [posts multipart form data]
POST https://[moodle website]/repository/draftfiles_ajax.php [posts some params]
GET https://[moodle website]/draftfile.php/[some_id]/user/draft/[some_id]/[somefilename.png] [returns an icon of the image for a filepicker from YUI]
POST https://[moodle website]/mod/quiz/processattempt.php [returns HTML page]
GET https://[moodle website]/mod/quiz/summary.php [returns HTML page]
Some of these scripts return, as you'd expect, JSON data since they're AJAX and not HTML. The final two calls (4 & 5) return HTML. Now, I can make all of those calls in succession in either the WebView or the Apache HTTP library, but if I do so with WebView, only JSON data is returned to the WebView in calls 1-3 (WebView treats the JSON data as a page and displays it wiping out whatever HTML page was displayed in it). If I capture and process the JSON data using the Apache HTTP library in Java, then the JavaScript components internal to the page do not get updated. If I split the calls so that I send only calls 4 & 5 to the WebView, the HTML merely returns WebView to the first question of the exam and Moodle acts as if I haven't uploaded anything.
I can verify that files are uploading if I manually refresh (press a link) the JavaScript UI elements in the page. I can't expect students to do this, though, because the link to do so is very tiny and it's not obvious that it does a refresh. I need a way to programmatically refresh this one element (it's part of YUI) or to get Android and the Java side to play more nicely with the JavaScript/DOM side.
My question is: does anyone know a way to 1) fire off a drag and drop event using YUI to an element inside an HTML page or 2) a way to consume the JSON data and pass it to an element inside the HTML page.
I'm banging my head against a wall trying to figure this out.
OK, so I figured out that: javascript:document.getElementsByClassName(\"[name of link here]\")[0].click() works in Chrome on the desktop but doesn't work if I pass it to WebView.loadURL(). I just need to be able to simulate that click event reliably in WebView. It appears not to support click(). Anyone have any ideas?
The winning code is:
el = document.getElementsByClassName("[some element]")[0];
var event = document.createEvent("MouseEvents");
event.initEvent("click", true, true);
el.dispatchEvent(event);
This selects the link at [some element] and thereby fires an AJAX request that refreshes the FilePicker. For those working with Moodle, I had to add the above code to the same quiz question that handles so it is invoked by putting that code in its own function and calling it with WebView.loadURL("javascript:myRefreshFunction()").
I have a swing application that sends commands to server and receives result in XML format. I need to transform this into HTML via XSLT and then display result HTML on the panel. The problem is that the only Swing component which is able to display HTML - JEditorPane - takes either URL or javax.swing.text.StyledDocument as a source.
Option with URL doesn't work for me because I have to save my html as a file on the file system first and I'd like to avoid this.
So I have a gap between in-memory result of XSL transformation and javax.swing.text.StyledDocument, which can be rendered by JEditorPane or JTextPane.
How to transform one to another? Or are there any other Swing solutions to display HTML from some in-memory source(DOM or String or whatever)?
Thank you in advance for help.
Is there a reason that JEditorPane.setText() does not work for you?
I use JEditorPane all the time and I've never pulled the displayed data from a file or URL. So it is possible. Just need to figure out why it's not working for you.
To be specific:
editor.setContentType( "text/html" );
editor.setText( "<html><body>Hello, world</body></html>" );
What about JeditorPane.setText() ?