Skip to main content

All Questions

Tagged with
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
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
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
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
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
56 votes
1 answer
5k views

Java thread leaks when calling back from native thread via JNI

Summary: I am seeing Java thread leaks when calling back into Java from native code on a natively-created thread. (Update 11 Feb 2014: We raised this as a support request with Oracle. It has now been ...
Malcolm Wilkins's user avatar
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
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
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
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
26 votes
1 answer
29k views

Need to wait for asynchronous api callback before I return from method in Java

import java.util.concurrent.CountDownLatch; import quickfix.Initiator; public class UserSession { private final CountDownLatch latch = new CountDownLatch(1); public String await() { ...
shaz's user avatar
  • 2,377
24 votes
3 answers
9k views

How to avoid memory leaks in callback?

Effective Java says: A third common source of memory leaks is listeners and other callbacks. If you implement an API where clients register callbacks but don’t deregister them explicitly, ...
unj2's user avatar
  • 53.2k
22 votes
3 answers
7k views

Java: How to call super method from inner in-place class

I have base class Foo with method spam and class Bar which overrides spam. I need to call spam of base class in method of some callback object which is defined in-place: public class Foo { public ...
Vlad's user avatar
  • 1,670
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

15 30 50 per page
1
2 3 4 5
55