Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active April 10, 2020 15:59
Show Gist options
  • Save duytq94/872a738e63295ea4c290166934bc1917 to your computer and use it in GitHub Desktop.
Save duytq94/872a738e63295ea4c290166934bc1917 to your computer and use it in GitHub Desktop.
class TestConnectNativeModule internal constructor(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
override fun getName(): String {
return "TestConnectNative"
}
@ReactMethod
fun sendMessageToNative(rnMessage: String?) {
Log.d("This log is from java", rnMessage)
}
@ReactMethod
fun sendCallbackToNative(rnCallback: Callback) {
rnCallback.invoke("A greeting from java")
}
@ReactMethod
fun finishActivity() {
if (currentActivity != null) {
currentActivity!!.finish()
}
}
@ReactMethod
fun goToSecondActivity() {
if (currentActivity != null) {
val intent = Intent(currentActivity, SecondActivity::class.java)
currentActivity!!.startActivity(intent)
}
}
companion object
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment