Asked  1 Year ago    Answers:  5   Viewed   13 times

Can anyone tell me if an equivalent for setInterval/setTimeout exists for Android? Does anybody have any example about how to do it?



As always with Android there's lots of ways to do this, but assuming you simply want to run a piece of code a little bit later on the same thread, I use this:

new android.os.Handler(Looper.getMainLooper()).postDelayed(
    new Runnable() {
        public void run() {
            Log.i("tag", "This'll run 300 milliseconds later");

.. this is pretty much equivalent to

    function() {
        console.log("This will run 300 milliseconds later");
Tuesday, June 15, 2021

There are no interfaces in ruby since ruby is a dynamically typed language. Interfaces are basically used to make different classes interchangeable without breaking type safety. Your code can work with every Console as long it behaves like a console which in C# means implements IConsole. "duck typing" is a keyword you can use to catch up with the dynamic languages way of dealing with this kind of problem.

Further you can and should write unit tests to verify the behavior of your code. Every object has a respond_to? method you can use in your assert.

Thursday, August 12, 2021

Java applets were "the new hot thing" in 1997, when Java 1.0 came out. After a few years, they became less and less popular, mainly because installing Java on a computer was a big hurdle for many people (you had to download the whole JRE, which was big, it took a long time to install and Java was not that fast at that time - so many people saw it as a slow, bloated thing).

Macromedia Flash (which became Adobe Flash later, ofcourse) had advantages over Java applets in this regard - the plug-in was quick and easy to install, and so it became the dominant thing for interactive multimedia stuff on the web.

Microsoft's Silverlight is meant to be a competitor for Flash and Sun's JavaFX.

JavaFX is Sun's technology that should make it easy to do Flash-like things on the Java virtual machine. If JavaFX becomes a success, then Java applets using JavaFX might become popular again.

Note that earlier this year, Sun released a completely rewritten Java browser plug-in which is quicker and easier to install than the old plug-in. On of the things Sun is working on is making it just as easy to install the Java plug-in as it is to install the Flash plug-in.

Saturday, August 14, 2021

Yes it's possible by installing Java-JS bridge and then injecting JS into page that collects the data and returns it via JS bridge. See this answer: How to call javascript from Android?

Sunday, August 15, 2021

Crosswalk support the similar API interface (evaluateJavascript) as Android WebView for calling JavaScript function from Java:, )

You can also use load for calling javascript function directly like: xwalkView.load("javascript:" + jsCode, null).

did you meet any issue with the Crosswalk API?

Monday, October 18, 2021
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :