Last active
April 10, 2020 15:59
-
-
Save duytq94/872a738e63295ea4c290166934bc1917 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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