https://kotlinlang.org logo
Title
k

Kashif

01/07/2020, 12:10 PM
I have a webview in android kotlin and i want to read this json defined in
postMessage
. what is best possible way for it?
:google: 2
:stackoverflow: 2
d

dawidhyzy

01/07/2020, 12:11 PM
k

Kashif

01/07/2020, 12:11 PM
i tried but not able to find much for
postMessage()
i mostly find answers for showHtml
d

dawidhyzy

01/07/2020, 12:13 PM
This is wrong place to ask such question. It’s not Kotlin specific. Just check the channel topic…
k

Kashif

01/07/2020, 12:15 PM
ok i guess #javascript will be good place to ask
c

Can Orhan

01/07/2020, 12:17 PM
I don’t think so. That channel seems to be aimed at kotlin/js code - which this is not. Though I haven’t used it myself, I recommend looking for an Android slack group like Android United. Best of luck! https://slofile.com/slack/android-united
👍 3
h

Hitender Pannu

01/07/2020, 3:27 PM
look for "@JavascriptInterface" may be it will help
r

rkeazor

01/07/2020, 3:33 PM
Also try android documentation. Developers.android.com
e

Eileen

01/07/2020, 4:02 PM
hi you can use the
@JavascriptInterface
annotation and have a when for the method and then put in what you need to do with the json inside
easiest way for webview interactions
k

Kashif

01/07/2020, 5:24 PM
thanks all for your help. i found the solution just adding for reference here is my javascript
and here is my code which uses
@JavascriptInterface
and Toast the json