In my app I have a webview to show the user some information from a web page. Before seeing the info though, you have to choose an option on a dropdown list on the webpage. Is there any way I can choose the right option for the user (via code) and only have them see the content?
You can run arbitrary javascript inside a WebView, initiated from Java. Be sure you have javascript enabled. Once you've done that,
theWebView.loadUrl( "javascript:alert('Hello')" );
is the mechanism to invoke javascript functions or scripts. To pre-select a drop-down, you may want to include jquery or such, making the selection easier.
Related
I got a flash document I CAN'T modify, that starts its animations only when pressing a button it has on it. I tried EVERY script I found on the internet but nothing worked. I need to simulate the click on that button so the flash animation can start! Is this possible?
If there are no APIs (which give you access to the elements),
you cannot interact with the Flash UI, because the Flash content has its own context, where JavaScript has no access to it.
You can try to decompile your flash file and get FLA-project of it. There it is possible to make required changes and create new swf.
There are many swf decompilers, but there is no 100% guarantee for successful decompilation (especially for big and complicated flash applications)
I want to add a functionality in my app which submits a review of a place on the place's google plus account ..
As you might be knowing the format of the google plus page ..
It has a button "Write a review" (Which is not a button but a clickable 'div')
On pressing this button , a dialogue appears which has a field to write review , It is here i want to actually write the review through the code and press the submit button .
Please help me through this ..
How to achieve this thing ??
Jsoup parses HTML. It does not execute JavaScript or emulate a browser, so there's no dialog box for it to interact with.
You could try using a browser's network monitor feature (part of their developer tools) to see what requests are made when the dialog box is submitted, then simulate those requests from your application. You could also see if there's a Google+ API for submitting reviews other than from the place's Google+ page. APIs are easier to use, robust against changes in the web page's HTML, and don't risk violating terms of service that prohibit automation. Finally, you could try a browser automation tool (commonly used for unit testing web pages); I don't know of any for Android but I'd be surprised if there aren't any.
BACKGROUND
I'm doing an interactive art project for school.
PROCESS
For this project the last step is to go to a facebook fanpage and like the facebook page.
ASSUMPTIONS
I'll be using Java to open up a browser and then go to the facebook page. However, I would like to use something like one line of script to like the facebook fanpage.
PROBLEM
Is there will be no mouse for this interaction.
SOLUTIONS
Is there a script I (or stackoverflow) can write that I may execute that will like a facebook page?
Or is there any other solution that you guys can think of?
TOOLS/LANG. BEING USED: ARDUINO/JAVA, HTML, JAVASCRIPT and CSS.
You could use a browser automation framework like Selenium to load the Facebook page and simulate clicking on the Like button, but you would have to log the correct user in first. Selenium has a Java interface you could use.
Alternatively, if you are having it run on a single machine you control, you might have luck with doing some sort of userscript (something like this one) for the Facebook site so that when they are on the correct page, it clicks the Like button automatically. Then all you would have to do is launch the page from Java in the correct browser, and the userscript would do the rest. Note: Userscripts work on Firefox with GreaseMonkey installed, and on Chrome/Chromium without any extensions.
Make an application on Facebook and use their api to interact with the page: Facebook API
Alternatively, use some javascript to like the page once you navigate to it
I spent hundreds of hours writing an HTML5 application.This application deals with multiple popups and I suddenly ran into a problem when managing them.
My main goal would be bring a blurred popup window to front by focusing it.I am wondering if this is possible in JavaScript.
If not, could I use java applet in order to gain more functionality on my popup windows. Could I perhaps embed Google V8’s engine in order to render my existing HTML5 code in this application?
when you open a window you create a reference to it. You can then use that reference to call focus() on.
var foo = window.open( /*params*/ );
foo.focus();
I am using the WebkitBrowser to run a browser app like on my desktop. I want to know it's possible for the WebkitBrowser widget to listen for javascript calls made when the user interacts with the browser applications' buttons.
I don't know if this will help but I am building the browser app with Ext GWT.
I'm not so familiar with WebkitBrowser, but it looks like at the very least you could use a StatusTextListener to listen for changes in the status bar text and have Javascript modify that by editing the window.status field.
Also, I don't know how attached you are to WebkitBrowser, but the standard SWT Browser widget does support Javascript to Java communication through the BrowserFunction object.
Here's an example of using the BrowserFunction class from SWT snippets:
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java?view=co