All Questions
813
questions
0
votes
2
answers
67
views
How can a Callable return a value from a predefined void callback?
I am using a data-related API interface which has a key void callback function that is automatically invoked to mark the end of some IO operations. I want to make the class Callable<String> and ...
-2
votes
0
answers
59
views
Can callback to an incompletely constructed Java object be well-defined?
If a constructor of a class T passes this to as an argument to some method foo, and foo immediately performs a callback to the T object (which has not yet finished executing its constructor), things ...
2
votes
1
answer
79
views
Java - Use null comparison or instanceof?
Below is a Java class constructor which accepts a callback for error handling. null should be an acceptable value, and if the passed value is null then skip error handling.
I have two ways of checking ...
0
votes
1
answer
37
views
linked hashmap get the first inserted
I have this LinkedHashMap which keep the order of the K-V pairs on the insertion order.
Map<Integer, String> map = new LinkedHashMap<>();
for (int i = 0; i < 1000000; i++) {
if (i =...
0
votes
0
answers
63
views
TelephonyCallback.CallStateListener with LiveData and ViewModel
I'm new to both android and java, now im trying to update a textview with the state of the call, but the view model doesn't get the value from the telephony callback class.
Im using post value since ...
0
votes
1
answer
23
views
How to get variable from GWT Callback
I'm trying to get a state of a server variable using a callback. Obviously, the state is always false. How can I get the state from the server? Or another question, which options do I have to get ...
0
votes
0
answers
105
views
How can I use APISetu to get documents from DigiLocker
I am trying to integrate DigiLocker APISs into my program. I am confused about lots of things, I need stepwise details to use DigiLocker to perform the following tasks:
First open DigiLocker page for ...
0
votes
1
answer
51
views
Java - receive a method that takes any number/type of parameters as method parameter
I'm implementing a Console Menu class in Java, roughly it looks like this:
public class ConsoleMenu {
private Scanner s = new Scanner(System.in);
private ArrayList<String> menuItems = ...
0
votes
1
answer
84
views
Calling functions from WebView to JS
In the java code(container) i have to get some values by calling some javascript functions, for this im using webView.evaluateJavascript, the problem is that i get the callback only when all the code ...
0
votes
1
answer
2k
views
onBackPressed is deprecated - webView in android app
I have an app where the main activity (which extends ComponentActivity) is pretty much just a webView. I have overriden onBackPressed, shown below.
@Override
public void onBackPressed(){
if(this....
1
vote
1
answer
96
views
Make a callback with JAVA RMI
I am currently implementing a kind of bag of tasks using Java RMI. The goal is for a "Client" to submit "Task" objects to a "Server," and on the other hand, I have "...
0
votes
1
answer
43
views
What thread should callbacks occur on in Java?
I'm developing a Java library that runs a scheduled task in a ScheduledExecutorService. If the user specifies callback(s), then after that task, those callback(s) will be invoked.
Right now I just ...
4
votes
0
answers
32
views
Register a callback to handle JLI_Launch failing with "Could not find or load main class"
I am trying to make AppBundler more observable and have had great success except for one thing. JLI_Launch does not return to the caller so I can't tell if it fails to load the main class (or any ...
0
votes
0
answers
46
views
Can we send back data from App to Chrome in previous opened Tab?
I have made a payment app in Java Kotlin. My requirement is that a webpage can call my app for payment then after successful payment I can response back that webpage with transaction ID.
From web page,...
0
votes
0
answers
19
views
The invalidate function[inside onChildAdded firebase's callback] doesn't invoke onDraw
Have a good day.
Actually, I have faced an issue, in which, the onDraw function is not being executed when onChildAdded is being invoking inside onChildAdded callback for firebase.
...
0
votes
1
answer
493
views
Issue with CallbackQuery in Telegram bot
I'm trying to create an Inline Keyboard Markup in my telegram bot using java (Maven project using TelegramBotsApi v 6.7.0). This includes handling call back queries from user to take some decision ...
0
votes
2
answers
550
views
How to handle an instant response from an external API and a callback response in a single controller in Spring Boot?
I have a controller from where I am trying to trigger an POST external api call using headers and request body.
Sample external API URL:
http://sample:7070/test
Sample Headers:
Content-type: ...
0
votes
1
answer
370
views
How to receive callback with app in background
I would like to be able to receive a callback when my app is in the background and then switch back to the application without any manual steps from the user when the callback is received. An activity ...
1
vote
0
answers
152
views
Design classes using Spring boot, JPA using callbacks of generic type
I'm confused about the design using Spring boot and JPA when callbacks are involved.
Example:
Controller will call the Service class and pass in the value of T, i.e Employee in our example:
@...
0
votes
1
answer
51
views
Junit, How to cover the callback code using Junit?
I have to write a test case to cover a method which has a callback as one of the parameters. It looks something like the snippet below.
JAXBElement<MyCustomObject> obj = null;
try {
obj = (...
0
votes
1
answer
72
views
java how to manage callback correctly
I will try to be clear with my question.
I had a callback function in a class like that, udes to retrieve card information from a reader.
public void CallbackFunction(CardContent PresentedCard) {
...
0
votes
1
answer
48
views
Create callback Class
Hey I am using firebase callback that call PhoneAuthProvider
what I want to do is to wrap this callback in class and create an instance of this class in multiple Classes instead of writing this ...
1
vote
1
answer
211
views
How to deliver the result of asynchronous request from back to front (Callback)
Client send a request to my my service "A" then I send a request from service "A" to Camunda like "doSmthAndGet" then camunda replies "request accepted" and ...
0
votes
2
answers
385
views
Callback with 3 parameters
In modern Java, using a callback (a.k.a. function reference a.k.a. function pointer) with up to two parameters is pleasantly easy and straightforward. Example:
class a {
public static Object plus(...
0
votes
1
answer
73
views
Callback function's byte parameter has value out of bounds in project Panama function interface
I'm using the new Foreign function & memory API which is part of project Panama and available in preview in JAVA 19.
This is a simple Java callback function
public static byte addFive(byte t) {
...
-2
votes
1
answer
27
views
Why can't it be overridden, if possible?
I'm learning Java, I met an example of Closure:
public class Callbacks {
public static void main(String[] args) {
Callee1 c1 = new Callee1();
Callee2 c2 = new Callee2();
...
1
vote
1
answer
118
views
Post callback for JVM out of memory
In our java application, we need to send email in case the application goes out of memory and recovers from it by its own. To do so, we need a callback kind of thing that should be called once the JVM ...
0
votes
1
answer
37
views
Controlling user input with callback functions in Java
First of all I am totally new to Java and trying to understand POO.
Presentation :
In a class, I defined a method called inputCapacity. I would like my user to enter a number between 1 to 4. In a way ...
0
votes
2
answers
486
views
How to garbage collect callbacks with weak references in Java?
I'm reading Effective Java by Joshua Bloch. In Item 7: Eliminate Obsolete Object References of chapter 2 he states:
A third common source of memory leaks is listeners and other
callbacks. If you ...
0
votes
0
answers
76
views
Android Java - Pass Class and Callback as parameter and instantiate object inside function
I need your help in understanding the best way of doing this. Given the sample code below, I need to know how to pass a Class and a Callback via parameter and use them internally to instantiate an ...
1
vote
1
answer
246
views
How to change order of callbacks in spring data jdbc?
How to change order of callbacks in spring data jdbc? Primary, order, dependsOn used, didn't help.
@Bean
AfterDeleteCallback<? extends Document> test() {
return (document) -> {
...
-2
votes
1
answer
262
views
Why is the double colon operator needed in Java? [duplicate]
I'm coming from a JavaScript background and I'm seeing the :: operator for the first time. I understand what it does, but I'm wondering why it's necessary. In JavaScript, something like this is ...
0
votes
1
answer
90
views
Class A function calls a function in Class B , Once it's completed how to get notification to Class A (Android Java)
Here is the thing that I need to do.
When the user click on a button on an activity , the app must call a function in different class and sent back a notification to the activity. Then the activity ...
0
votes
0
answers
48
views
Is it possible to compare two seperate instances of objects that are considered callbacks using the equals() method?
I have two seperate objects that are from the same class, and using them as callbacks.
I would like to compare them at runtime in my app, because I'm relying on the equals method in some collection to ...
1
vote
1
answer
675
views
Java: Callback to main Thread
How can I make the callback execute in the "main thread"?
@Test
void threadTest() throws InterruptedException {
System.out.println("main thread:" + Thread.currentThread());
...
1
vote
1
answer
143
views
How to return a value retrieved inside a callback function's void overriden method?
I have the following function, which returns a long value. However, that long value (result.id.longValue()) is retrieved inside a callback's void overridden method, so I can't just return the ...
0
votes
2
answers
937
views
Merge two responses
The firstResponse and secondResponse should be combined into CombinationBothResponses and returned when the GET endpoint 127.0.0.1:8081/comb is called. However, the correctly combined response is ...
1
vote
1
answer
97
views
Best way to sort strings of filepaths into a directory structure?
I am using contentService.streamDirectory to get a callback containing all directories/files within a BitBucket project, then I am using a for loop and "callback.getFiles().get(i).toString()"...
1
vote
1
answer
214
views
JNA: Callback returns null value
I am using custom types in the callback method and always get an empty value. What could be the problem?
C code in dll(i have .h file for this dll):
typedef union
{
char caStruct[16384];
struct
...
1
vote
0
answers
116
views
How to have Process spawned by ProcessBuilder run a callback on completion/termination?
I'm writing a separate thread to monitor an OS process spawned by Java's ProcessBuilder. The process can sometimes get out of control. After a given timeout period, I want to kill the process if it's ...
2
votes
1
answer
547
views
Pointer to a function in java
I have a dynamic link library (DLL) written in c++. In my DLL I have a function like this:
void set_event_callback(EVENT_CALLBACK callback_fcn);
where EVENT_CALLBACK is a function pointer like this:
...
0
votes
0
answers
79
views
Inner class seems unnecessary in the example given in On Java 8 by Bruce Eckel
Bruce Eckel gives the following example in Chapter Inner Classed of the book On Java 8 to demonstrate the necessity of using an inner class instead of implementing an interface. But I found the code ...
0
votes
1
answer
250
views
android callback with firestore not working [duplicate]
i'm trying to get data from firestore and i want to get data before executing the rest of the code so i used callbacks
at first i created a class DbManger with a static methode and an interface
public ...
0
votes
2
answers
1k
views
Spring Boot RestTemplate get Cookie from Callback
I would like to retrieve a jwt token, using Spring RestTemplate, from a callback that is a redirect URL from a login URL.
I have been able to connect to the login URL, I have been able to follow the ...
0
votes
1
answer
286
views
Flyway migration and callbacks (java)
colleagues! I'm using flyway migration and want to use callback after my own schema is created. Is it possible to do it and how?
0
votes
2
answers
64
views
I can not stop a Runnable using Handler in JAVA
I am trying to build a stopwatch and i have a button named start which starts the counting, after it starts the name of the button changes to stop and when i press stop i want to pause the counting, ...
0
votes
1
answer
395
views
Handle Callback Exceptions In Another Method
I am connecting to a database and I want to make queries using callbacks, so I wrote this:
public void query(String query, Consumer<ResultSet> callback, String database) throws SQLException {
...
0
votes
0
answers
87
views
JNA callback method wont be called until futureTask.get() timeout
If I run like this, the callback block will not run so future.get() will block forever:
FutureTask<Long> futureTask = new FutureTask<>(System::currentTimeMillis);
boolean login = ...