Skip to main content

All Questions

Tagged with
192 votes
12 answers
170k views

Java executors: how to be notified, without blocking, when a task completes?

Say I have a queue full of tasks which I need to submit to an executor service. I want them processed one at a time. The simplest way I can think of is to: Take a task from the queue Submit it to ...
Shahbaz's user avatar
  • 10.5k
210 votes
18 answers
325k views

Callback functions in Java

Is there a way to pass a call back function in a Java method? The behavior I'm trying to mimic is a .Net Delegate being passed to a function. I've seen people suggesting creating a separate object ...
Omar Kooheji's user avatar
  • 55.3k
77 votes
5 answers
226k views

How do I perform a JAVA callback between classes? [duplicate]

I am coming from JavaScript, in which callbacks are pretty easy. I am trying to implement them into JAVA, without success. I have a Parent class: import java.net.Socket; import java.util.concurrent....
Ágota Horváth's user avatar
256 votes
9 answers
141k views

How to remove all callbacks from a Handler?

I have a Handler from my sub-Activity that was called by the main Activity. This Handler is used by sub-classes to postDelay some Runnables, and I can't manage them. Now, in the onStop event, I need ...
Luke Vo's user avatar
  • 19.8k
62 votes
6 answers
76k views

What is a callback method in Java? (Term seems to be used loosely)

I don't understand what a callback method is and I have heard people use that term very loosely. In the Java world, what is a callback method? If someone could provide some example code of a Java ...
Horse Voice's user avatar
  • 8,258
60 votes
9 answers
46k views

method called after release() exception unable to resume with android camera

While developing a camera app I've encountered an exception that only happened when I switch to other app (onPause() for my app). 01-15 17:22:15.017: E/AndroidRuntime(14336): FATAL EXCEPTION: main 01-...
tom91136's user avatar
  • 8,862
38 votes
4 answers
53k views

Automatically log Android lifecycle events using ActivityLifecycleCallbacks?

I am trying to automatically capture and log Android lifecycle events using ActivityLifecycleCallbacks, however documentation on this matter is scarce, to say the least: public void ...
AWT's user avatar
  • 3,677
40 votes
1 answer
37k views

JNI - How to callback from C++ or C to Java?

I have Java application that invokes native C++/C code. The C++/C code needs to callback into Java. Could you give me some examples how to do this.
garfield's user avatar
  • 421
12 votes
1 answer
15k views

Callback from Adapter

So I have a custom listview. It's like Instagram layout with 1 image and bunch of buttons in each list items. So here's the problem: I want to implement the share button. To do this, I tried to ...
Wiillyx3's user avatar
  • 151
9 votes
3 answers
18k views

How to create a proper Volley Listener for cross class Volley method calling

I aim to call Volley from another class in, a very succinct, modular way ie: VolleyListener newListener = new VolleyListener(); VolleySingleton.getsInstance()....
Sauron's user avatar
  • 6,549
18 votes
2 answers
25k views

Implement callback function in JNI using Interface

I need to implement callback function in Java using “interface”. I have wrote the application part as MyJavaFunction(int size, m_GetSizeInterface); m_GetSizeInterface is an Interface which contains ...
indira's user avatar
  • 6,667
14 votes
5 answers
20k views

Java set a callback from ExecutorService

I have a fixedThreadPool that I am using to run a bunch of worker threads to achieve parallel execution of a task with many components. When all threads have finished, I retrieve their results (which ...
Alex's user avatar
  • 18.5k
45 votes
4 answers
9k views

Java pattern for nested callbacks?

I'm looking for a Java pattern for making a nested sequence of non-blocking method calls. In my case, some client code needs to asynchronously invoke a service to perform some use case, and each step ...
Andrew Swan's user avatar
  • 13.6k
22 votes
4 answers
25k views

SOAP web service callback architecture?

I am quite new to web services, JAX-WS etc. so maybe noob question... So, I want to implement a web service to make two systems communicate. The "client" system is interested in events that are ...
Pierre Henry's user avatar
  • 17.2k
36 votes
1 answer
16k views

Using Mockito, how do I intercept a callback object on a void method?

I'm using mockito to test a legacy JAAS/LDAP login module. The javax.security.auth.callback.CallbackHandler interface defines the function: void handle(javax.security.auth.callback.Callback[] ...
brasskazoo's user avatar
  • 77.9k

15 30 50 per page
1
2 3 4 5