安卓一键分享解决方案
来源:互联网 发布:网络公安报警电话 编辑:程序博客网 时间:2024/05/19 13:15
安卓一键分享解决方案
概要 开发者仅需10分钟即可集成到自己的App中,支持国内外40多家的主流社交平台,有强大的社会化统计分析管理后台,可以实时了解用户、信息流、回流率、传播效率等数据。
主要功能及优点
1.一键分享,支持分享文字、图片、图文、音乐、视频、链接
2.支持绝大部分社交平台
3.体积小,集成方便
模块集成主要步骤
去mob官网下载sharesdk(下载页面)
进入ShareSDK解压目录,打开“Share SDK for Android”目录,可以找到“QuickIntegrater.jar”,这个就是快速集成ShareSDK的工具 .
Windows下
首先确定您已经安装了JDK,并且正确配置了JAVA_HOME和PATH系统变量,此时您可以双击QuickIntegrater启动程序
Linux/Mac OS下
同样需要先确保已经正确配置了JDK,之后启动终端,cd进入“Share SDK for Android”目录,输入: java -jar QuickIntegrater.jar 可启动QuickIntegrater
填写自己项目的名字与包名,点击确定之后会在当前目录创建一个文件夹,将这文件夹的所有内容复制到你的项目中
如果载入进去后有的类出现乱码,则右键项目选择properties,将编码格式修改为UTR-8
配置Androidmanifest.xml文件
添加权限
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
<uses-permission android:name=
"android.permission.GET_TASKS"
/>
<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.CHANGE_WIFI_STATE"
/>
<uses-permission android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission android:name=
"android.permission.MANAGE_ACCOUNTS"
/>
<uses-permission android:name=
"android.permission.GET_ACCOUNTS"
/>
<!-- 蓝牙分享所需的权限 -->
<uses-permission android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission android:name=
"android.permission.BLUETOOTH_ADMIN"
/>
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
<activity
android:name=
"com.mob.tools.MobUIShell"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar"
android:configChanges=
"keyboardHidden|orientation|screenSize"
android:screenOrientation=
"portrait"
android:windowSoftInputMode=
"stateHidden|adjustResize"
>
<intent-filter>
<data android:scheme=
"tencent100371282"
/>
<action android:name=
"android.intent.action.VIEW"
/>
<category android:name=
"android.intent.category.BROWSABLE"
/>
<category android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!--微信分享回调 -->
<activity
android:name=
".wxapi.WXEntryActivity"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar"
android:configChanges=
"keyboardHidden|orientation|screenSize"
android:exported=
"true"
android:screenOrientation=
"portrait"
/>
<!--易信分享回调 -->
<activity
android:name=
".yxapi.YXEntryActivity"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar"
android:configChanges=
"keyboardHidden|orientation|screenSize"
android:exported=
"true"
android:screenOrientation=
"portrait"
/>
在ShareSDK.xml中替换mob后台申请的Appkey与各个平台申请的key(注:mob后台申请的appkey可在mob官网注册后申请获得。demo中各个平台的key是mob注册申请的,如果开发产品则需要开发者去各个平台申请key)
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
1、表格中的第一项
<ShareSDK
AppKey="api20" />
是必须的,其中的AppKey是您在ShareSDK上注册的开发者帐号的AppKey
2、所有集成到您项目的平台都应该为其在表格中填写相对应的开发者信息,以新浪微博为例:
<SinaWeibo
Id="1"
SortId="1"
AppKey="568898243"
AppSecret="38a4f8204cc784f81f9f0daaf31e02e3"
RedirectUrl="http://www.mob.com"
Enable="true" />
其中的SortId是此平台在分享列表中的位置,由开发者自行定义,可以是任何整型数字,数值越大
越靠后AppKey、AppSecret和RedirectUrl是您在新浪微博上注册开发者信息和应用后得到的信息
Id是一个保留的识别符,整型,ShareSDK不使用此字段,供您在自己的项目中当作平台的识别符。
Enable字段表示此平台是否有效,布尔值,默认为true,如果Enable为false,即便平台的jar包
已经添加到应用中,平台实例依然不可获取。
各个平台注册应用信息的地址如下:
新浪微博 http://open.weibo.com
腾讯微博 http://dev.t.qq.com
QQ空间 http://connect.qq.com/intro/login/
微信好友 http://open.weixin.qq.com
Facebook https://developers.facebook.com
Twitter https://dev.twitter.com
人人网 http://dev.renren.com
开心网 http://open.kaixin001.com
搜狐微博 http://open.t.sohu.com
网易微博 http://open.t.163.com
豆瓣 http://developers.douban.com
有道云笔记 http://note.youdao.com/open/developguide.html#app
印象笔记 https://dev.evernote.com/
Linkedin https://developer.linkedin.com
FourSquare https://developer.foursquare.com/
搜狐随身看 https://open.sohu.com/
Flickr http://www.flickr.com/services/
Pinterest http://developers.pinterest.com/
Tumblr http://www.tumblr.com/developers
Dropbox https://www.dropbox.com/developers
Instagram http://instagram.com/developer#
VKontakte http://vk.com/dev
易信好友 http://open.yixin.im/
明道 http://open.mingdao.com/
Line http://media.line.me/zh-hant/
Pocket http://getpocket.com/developer/apps/new
添加java代码
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
private
void
showShare() {
ShareSDK.initSDK(
this
);
OnekeyShare oks =
new
OnekeyShare();
//关闭sso授权
oks.disableSSOWhenAuthorize();
// 分享时Notification的图标和文字 2.5.9以后的版本不调用此方法
//oks.setNotification(R.drawable.ic_launcher, getString(R.string.app_name));
// title标题,印象笔记、邮箱、信息、微信、人人网和QQ空间使用
oks.setTitle(getString(R.string.share));
// titleUrl是标题的网络链接,仅在人人网和QQ空间使用
oks.setTitleUrl(
"http://sharesdk.cn"
);
// text是分享文本,所有平台都需要这个字段
oks.setText(
"我是分享文本"
);
// imagePath是图片的本地路径,Linked-In以外的平台都支持此参数
oks.setImagePath(
"/sdcard/test.jpg"
);
//确保SDcard下面存在此张图片
// url仅在微信(包括好友和朋友圈)中使用
oks.setUrl(
"http://sharesdk.cn"
);
// comment是我对这条分享的评论,仅在人人网和QQ空间使用
oks.setComment(
"我是测试评论文本"
);
// site是分享此内容的网站名称,仅在QQ空间使用
oks.setSite(getString(R.string.app_name));
// siteUrl是分享此内容的网站地址,仅在QQ空间使用
oks.setSiteUrl(
"http://sharesdk.cn"
);
// 启动分享GUI
oks.show(
this
);
}
调用
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btShare = (Button)findViewById(R.id.bt_share);
btShare.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View v) {
// TODO Auto-generated method stub
showShare();
//点击打开一键分享菜单
}
});
}
如果上述文档不能满足你的分享需求,mob还提供了更高级的自定义功能。(点击跳转)
环境相关
开发平台:android
语言: java
开发工具: eclipse
效果展示
Note:本源代码由“极分享”社区创建,添加或者修改,我们会持续优化源代码以提供更好的解决方案,更多详情和支持请前往finalshares.com。
1 0
- 安卓一键分享解决方案
- 分享:Hierarchy Datagrid 解决方案
- [分享]食品行业ERP解决方案
- 移动BPM解决方案分享
- BPM SharePoint解决方案分享
- 分享IBM 行业解决方案集锦
- 房地产行业商业智能解决方案分享
- Android分享图片失败解决方案
- 秒杀高并发厂家解决方案分享
- BPM端到端流程解决方案分享
- BPM嵌入式流程解决方案分享
- BPM流程中心解决方案分享
- BPM协同平台解决方案分享
- BPM生产安全管理解决方案分享
- BPM任务管理解决方案分享
- BPM合同管理解决方案分享
- BPM公文管理解决方案分享
- BPM应用开发解决方案分享
- IO复用,select、poll、epoll综述
- 企业信息安全白皮书解决方案
- HDU 1010 Tempter of The Bone
- C++ 多线程拷贝文件(demo)
- BestCoder Round #50 digger(动态生成线段树)
- 安卓一键分享解决方案
- IOS--XML解析
- Prime Ring Problem
- jdk安装
- MySQL for Mac 安装和基本操作
- 透彻理解IOC
- 链接不上小米手机
- Intellij ideal 新建web项目的web资源目录不能自动映射问题
- TabBarViewController标签导航控制器全局控制