File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Problem Using ScheduledThreadPoolExecutor Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Mobile » Android
Reply Bookmark "Problem Using ScheduledThreadPoolExecutor " Watch "Problem Using ScheduledThreadPoolExecutor " New topic
Author

Problem Using ScheduledThreadPoolExecutor

Miko Diko
Greenhorn

Joined: Jun 27, 2011
Posts: 5
I'm coding a program which calls a servlet, gets Strings in return, and posts the Strings into an EditText.

The code works fine without using the ScheduledThreadPoolExecutor , but when I use it, debugging the servlet shows the request has arrived, and it returns a answer, yet the Android application never posts the String into the EditText.

I want the program to call the servlet every 1 second.
At the moment where the program needs to start polling, this code is activated:

Class data member :

private ScheduledThreadPoolExecutor timer = new ScheduledThreadPoolExecutor(1);

Code in class :

timer.scheduleAtFixedRate(new Runnable() {
public void run() {
try {
String[] recentEvents;
recentEvents = getAllEvents(); // Gets the strings from the servlet
if (recentEvents != null)
activateEvents(recentEvents); // Prints them to the EditText
} catch (IOException e) {
e.printStackTrace();
}
}
}, 100, 1000,TimeUnit.MILLISECONDS);
 
IntelliJ Java IDE
 
subject: Problem Using ScheduledThreadPoolExecutor
 
Threads others viewed
How to add actionListener to ScheduledExecutorService?
Cannot find the problem in the code
Call action class from timertask's run method
Keyboard events for EditText not reaching my event handler.
getText() help
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture