Add phonegap Baidu social sharing plug-in tutorial for Android

Here is the programming house jb51 CC collects and arranges code fragments through the network.

Programming house Xiaobian now shares it with you and gives you a reference.

1.下载插件包。


2. 解压所下载的包,从lib目录中得到所需要的所有的库:
Baidu-SocialShare-SDK-Android-2.0.0.jar


3. 修改AndroidManifest.xml,增加以下权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


4. 在AndroidManifest.xml中增加jar中需要的Activity。
<activity android:name="com.baidu.cloudsdk.social.oauth.socialOAuthActivity" android:exported="true"android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">

                    </activity>

<activity android:name="com.baidu.cloudsdk.social.share.handler.LocalShareActivity" android:launchMode="singleTask">

                    </activity>

<activity android:name="com.baidu.cloudsdk.social.share.handler.QQFriendShareReceiverActivity" android:launchMode="singleTask">

                 <intent-filter>

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />

<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="tencent此处为腾讯开放平台APPKey" />

                </intent-filter>

                 </activity>

<!-- 用户微信回调的 activity -->
<activity android:name=".wxapi.WXEntryActivity"
android:label="@string/app_name"android:exported="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">

                  </activity>

5.拷贝src文件夹里面的2个java文件到你的src中


6. 拷贝assert目录下config.json文件到你的项目对应文件夹里面。并修改为自己的信息。
{
client_ids:
{
baidu:"填写在百度开发者中心注册的app key",sinaweibo:"填写在微博开放平台注册的app key",qqdenglu:"填写在腾讯开放平台注册的app key",qqfriend:"填写在腾讯开放平台注册的app key",weixin:"填写在微信开放平台注册的app key"
},client_names:
{
qqfriend:"分享给qq好友所要显示的应用名称"
},supported_medias:
["sinaweibo","qqweibo","qqdenglu","kaixin","renren","qqfriend","weixin","weixin_timeline","email","sms"]
}


7.在config.xml文件下面引入插件(2.x 和3.x 的插件添加代码是不同的。)
<feature name=”Baidushare”>
<param name=”android-package” value=com.xhuayi.dgoula.Baidushare” />

</feature>


8. 修改HTML代码
引入baidushare.js文件到主文件里面
添加以下方法调用插件:
 
function shareClick(){
var title= “深圳市贸促委”;
var content = “深圳市贸促委品牌加盟展APP下载!”;
var url = “http://pic1.win4000.com/pic/6/3c/9b5f279921.jpg”;
var imageurl = “http://pic1.win4000.com/pic/6/3c/9b5f279921.jpg”;
window.plugins.Baidushare.bdshare(
title,content,url,imageurl,function(success) {
if(success == 1){
alert(“分享成功!”); //做业务处理
}else if(success == 2){
alert(“未分享成功!”);//做业务处理
}else{
alert(“encode success: ” + success);
}
},function(fail) {
alert(“encoding Failed: ” + fail);
}
);
}


KeyMob移动广告平台,创造更高的广告收入。

The above is all the code content collected by the programming home (jb51. CC). I hope this article can help you solve the program development problems you encounter.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>