正常に動作しているコードを共有しています。共有プラグイン機能についてはこのリンクを参照し、以下の手順に従ってください。
1- JS ファイルを MainActivity.java フォルダーの同じフォルダーに配置します。
2- Js ファイルを www フォルダーに配置し、index.html フォルダーに追加します。
3- 次の行を config.xml (新しいバージョンの Phonegap を使用している場合) または plugins.xml (古いバージョンの Phonegap の場合) に追加します。
4 - html を追加
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/libs/cordova-2.0.0.js"></script>
<script type="text/javascript" src="js/libs/jq_min.js"></script>
<script src="js/libs/share.js">
</script>
<script>
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
}
//share plugin for update status
function share(subject, text) {
window.plugins.share.show({
subject: subject,
text: text},
function() {
alert("sent success");}, // Success function
function() {alert('Share failed')} // Failure function
);
};
//Send message on facebook
$(document).ready(function() {
$("button#sendFacebook").click(function(){
var txtsub = $("input#txtsub").attr("value");
var txtmsg = $("#txtmsg").val();
share(txtsub, txtmsg);
});
});
</script>
</head>
<body>
<input id="txtsub" type="text" placeholder="Enter Subject" maxlength="20" required /><br/><br/>
<textarea placeholder="Enter Message" id="txtmsg" rows="4" cols="25"></textarea><br/>
<button id="sendFacebook">Update Status </button>
</body>
</html>
そして、Face book、twitter、gmail などでこのプラグインをテストして楽しんでください :)。
ご不明な点がございましたらお知らせください。