K1-Aria
K1-Aria

Reputation: 1146

how to open android default share dialog in webview

i have created an app using webview and now i want to create a share button (in web and js) to open android default share dialog for user.

But this approach does not work:

const sharePromise = navigator.share(data);

Because this is not supported in Android Web View. what can i do?

Upvotes: 1

Views: 1532

Answers (1)

A.Jain
A.Jain

Reputation: 46

you can open share by calling custom JS bridge function. Like below

@JavascriptInterface
fun share(pMessage: String) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_TEXT, pMessage);
sharingIntent.setType("text/plain");
startActivity(Intent.createChooser(sharingIntent, “ChooserTitle"));  
}

Upvotes: 1

Related Questions