You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Native Modules for React Native Android. I am using react native promises instead of callbacks to do some async task. Simple and Easy.
In Detail
I have a native module called "ReactNativeBridge" which has bunch of methods which are marked with @ReactMethod so they can be accessed from React Native side.
class ReactNativeBridge(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
@ReactMethod
printImage(imageUrl: String, promise: Promise) {
val currentActivity = currentActivity
if (currentActivity == null) {
promise.reject("Activity doesn't exist")
}
// Start activity which takes promise as an argument
val intent = Intent(reactApplicationContext.applicationContext, PrintActivity::class.java).apply {
putExtra(EXTRA_PRINT_DATA, somePrintData)
putExtra(EXTRA_PRINT_PROMISE, promise) // <---- here is the problem
}
currentActivity.startActivity(intent)
} }
As you can see I want to start a new Android activity in each of these methods and pass the Promise as an argument to those activities, through Intents. But I am unable to pass the promise through Intents since not all data types can be passed through Intents. I checked the type of promise, it is an Interface.
This is how a Promise Interface looks,
I know we cannot pass Interface since it is an abstract thing (like a blueprint).
** If your answer is "extend interface to Serializable" then remember I cannot modify Promise Interface. (It's a Facebook thing)
Questions
How to pass a Promise type through Intent ?
Is there any other approach to pass the Promise? Other than Intents.
The text was updated successfully, but these errors were encountered:
Thanks for posting this! It looks like your issue is missing some required information. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce your issue.
I am going to close this, but please feel free to open a new issue with the additional information provided. Thanks!
FYI: I am new to Android world.
What I am trying to do ?
I am using Native Modules for React Native Android. I am using react native promises instead of callbacks to do some async task. Simple and Easy.
In Detail
I have a native module called "ReactNativeBridge" which has bunch of methods which are marked with
@ReactMethod
so they can be accessed from React Native side.As you can see I want to start a new Android activity in each of these methods and pass the Promise as an argument to those activities, through Intents. But I am unable to pass the promise through Intents since not all data types can be passed through Intents. I checked the type of promise, it is an Interface.
This is how a Promise Interface looks,
I know we cannot pass Interface since it is an abstract thing (like a blueprint).
** If your answer is "extend interface to Serializable" then remember I cannot modify Promise Interface. (It's a Facebook thing)
Questions
The text was updated successfully, but these errors were encountered: