Android Phonegap 2.0 或更高版本 facebook、twitter、message 等共享插件的任何更新 [英] Android Phonegap version 2.0 or higher any update for Share plugin for facebook , twitter, message etc

查看:27
本文介绍了Android Phonegap 2.0 或更高版本 facebook、twitter、message 等共享插件的任何更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PhoneGap 共享插件对于 2.0 版本.我已经实施了,但无法正常工作.

I am trying to use the PhoneGap Share plugin for 2.0 version. I have implemented it but this is not work properly.

此插件是在 PhoneGap 1.0 及更高版本中编写的,用于在 Facebook 上共享消息的任何新插件或更新插件.

This plugin is written in PhoneGap 1.0 and later version any new or updated plugin for share message on Facebook.

我提到了这个 文档 和这个问题:如何在我的phonegap android应用中实现facebook发送、推特分享、发送短信、发送电子邮件?

I've referred to this documentation and this question: How to implement facebook send, twitter share, send sms, send email in my phonegap android application?

但仍然没有得到适当的解决方案.

But still not getting proper solution.

推荐答案

我正在分享我的代码,它运行良好.请参阅此链接以获取共享插件功能并按照以下给出步骤.

I am sharing my code which is working fine. Please refer This link for share plugin functionality and follow below given steps.

1- 将 JS 文件放在 MainActivity.java 文件夹的同一文件夹中.

1- Place the JS file in the same folder of the MainActivity.java folder.

2- 将 Js 文件放在 www 文件夹中,并将其添加到 index.html 文件夹中.

2- Place the Js file in the www folder and add it to the index.html folder.

3- 将以下行添加到 config.xml(如果您使用的是新版本的 Phonegap)或 plugins.xml(对于旧版本的 Phonegap):

3- Add the following line to the config.xml (if you are using new version of Phonegap) or plugins.xml (for old version of Phonegap):

4 - 添加 html

4 - add 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>

并为 Facebook、twitter、gmail 等测试此插件.&请享用 :).

and test this plugin for Face book,twitter,gmail etc. & enjoy :).

如果您有任何疑问,请告诉我.

Let me know if you have any query.

这篇关于Android Phonegap 2.0 或更高版本 facebook、twitter、message 等共享插件的任何更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆