Monaca Docs
Search…
Share Plugin (Android)
Share plugin lets an app to share data with other apps like Gmail, DropBox, etc.
This plugin is available only to Android platform.

Enable Plugin in Monaca

  1. 1.
    From the IDE menu, go to Configure → Cordova Plugin Settings.
  2. 2.
    Under Available Plugins section, hover over the Share plugin and click Enable button.

Methods

Function Name
Description
show(func)
Show a list of apps for user to choose and share the data when an app is selected.

Share Plugin Demo

1
<!DOCTYPE HTML>
2
<html>
3
<head>
4
<title>Cordova - Share Plugin Demo</title>
5
6
<meta charset="utf-8">
7
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
8
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: content: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
9
<script src="components/loader.js"></script>
10
<link rel="stylesheet" href="components/loader.css">
11
12
<script type="text/javascript">
13
14
function shareDemo() {
15
window.plugins.share.show(
16
{
17
subject: 'Subject test',
18
text: 'text http://phonegap-fan.com/'
19
},
20
function() {}, // Success function
21
function() {alert('Share failed')} // Failure function
22
);
23
}
24
</script>
25
</head>
26
27
<body bgcolor="#ffffff">
28
<hr> Share Plugin Demo<hr><br>
29
<input type="button" onClick ="shareDemo()" value ="shareDemo" />
30
</body>
31
</html>
Copied!
See Also:
Last modified 4mo ago