callback

Android make callback to an Activity from java class

爱⌒轻易说出口 提交于 2021-02-20 16:21:26
问题 How can i make a callback to an Activity form a Java Class? Example: public class TestClass{ String text = "Test"; public TestClass(Context context){ startActivity(new Intent(context, SomeActivity.class)); } private void sendToSomeActivity(){ //Call some method of SomeActivity and pas text as string } } When sendToSomeActivity() is called, i want to make a callback to the already started SomeActivity and pass some text to the Activity. In SomeActivity i want to use the text. Note: The

Android make callback to an Activity from java class

﹥>﹥吖頭↗ 提交于 2021-02-20 16:20:47
问题 How can i make a callback to an Activity form a Java Class? Example: public class TestClass{ String text = "Test"; public TestClass(Context context){ startActivity(new Intent(context, SomeActivity.class)); } private void sendToSomeActivity(){ //Call some method of SomeActivity and pas text as string } } When sendToSomeActivity() is called, i want to make a callback to the already started SomeActivity and pass some text to the Activity. In SomeActivity i want to use the text. Note: The

PHP callback: Is there an equivalent for ::class for a method of a class?

ぃ、小莉子 提交于 2021-02-20 02:52:15
问题 The bounty expires in 7 days . Answers to this question are eligible for a +50 reputation bounty. Blackbam wants to draw more attention to this question: A good solution shows a possibility to do this without passing a string but something which can be validated. If this is possible with two or three lines of codes using ReflectionClass this would totally be o.k. - I am just looking for a good way to solve this in a way such that I see an error in the IDE in case a method does not exist. In

Casting from member pointer to whole struct/class

a 夏天 提交于 2021-02-19 03:50:26
问题 Consider following code: #include <iostream> struct bar { double a = 1.0; int b = 2; float c = 3.0; }; void callbackFunction(int* i) { auto myStruct = reinterpret_cast<bar*>(i) - offsetof(bar, b); std::cout << myStruct->a << std::endl; std::cout << myStruct->b << std::endl; std::cout << myStruct->c << std::endl; //do stuff } int main() { bar foo; callbackFunction(&foo.b); return 0; } I have to define a callback function and I want to use some additional information in that function. I defined

Promisifying API callbacks - How to properly resolve or reject

不打扰是莪最后的温柔 提交于 2021-02-16 21:00:35
问题 I've read similar posts, but none quite hit on the head how to do this correctly. I understand Promises and how they are typically created with success and failure listeners waiting to be triggered to either resolve or reject. What I don't understand is when I'm calling an API method that takes a success and failure callback as parameters - how do I determine which callback is being triggered so I can then have it resolved or rejected? For example with this Web API and considering the

Promisifying API callbacks - How to properly resolve or reject

大憨熊 提交于 2021-02-16 21:00:10
问题 I've read similar posts, but none quite hit on the head how to do this correctly. I understand Promises and how they are typically created with success and failure listeners waiting to be triggered to either resolve or reject. What I don't understand is when I'm calling an API method that takes a success and failure callback as parameters - how do I determine which callback is being triggered so I can then have it resolved or rejected? For example with this Web API and considering the

How to check if caller still exist in task callback

允我心安 提交于 2021-02-11 18:10:12
问题 A very common scenario for a thread's callback is to inform the caller that it has finished his job. Here's the minimal example: class task { public: void operator()(std::function<void()>&& callback) { std::thread t { [c = std::move(callback)]{ std::this_thread::sleep_for(std::chrono::milliseconds{100}); c(); } }; t.detach(); } }; class processor { public: void new_task() { auto& t = tasks.emplace_back(); t([this]{ if (true/*this object still alives*/) finish_callback(); }); } private: void

node.js and AWS Lambda Function continue function execution after callback

若如初见. 提交于 2021-02-11 14:41:16
问题 I am trying to use a lambda function to alter a database and then send a push notification. I don't want to wait for the push notification server to reply. In the occasional case that the push notification is unsuccessful, that is not a concern. It is more important that the function executes in a timely manner. Currently I'm using the following two functions. Everything works as expected except that there doesn't seem to be any time saving. ie, when there is no device token and push is not

Callbacks between java and kotlin

二次信任 提交于 2021-02-11 12:23:59
问题 Initially, I had API calls in an adapter class which is in Java, I moved the API calls from the adapter to a presenter(Kotlin file). Adapter(java file) requests to do an API call, from adapter, code moves to presenter (kotlin file) presenter does the actual API call when the response comes or error, adapter methods need to be called. I implemented callbacks/interface, to do this Interface: interface ServiceOrderAdapterInterface { fun flOrderOfflineAcceptSuccess(flOrder: FlOrder) fun

Can I pass a Python “self” object to a C function as c_void_p and cast to original type for use in a callback?

爷,独闯天下 提交于 2021-02-11 06:16:41
问题 Using ctypes to interface my python3 code with a C API. One of the C functions registers a callback function– i.e. it takes a function pointer to the callback and a void* userdata to be made available in that callback. // typedef and C function in myClibrary.so typedef void(__cdecl *callback_function_type)(void*); int RegCallback(callback_function_type callback_function, void* userbdata); I have successfully defined the required callback function type in python using CFUNCTYPE() , passed an