android sharesdk 分享之后回调怎么写
1个回答
推荐于2016-08-15 · 知道合伙人影视综艺行家
关注
展开全部
android shareSDK 微博分享案例
ShareSDK
APP_KEY 219b1121fc68
腾讯微博
key 801517904
secret bfba83ae253c8f38dabe22c5fa4093bd
新浪微博
key 3815341537
secret f19fb8f89acc090716de7e3bde2e5f9e
包名+keySotre签名:91f05bce6758f1a1e870a4f3fa5f871b
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
准备阶段:
使用ShareSDK步骤
1. ShareSDK官网,创建应用 获取Key
2. ShareSDK官网,下载SDK
3. 使ShareSDK的DEMO正常运行
(类库:ShareSDK for Android
demo:ShareSDK for Android Sample)
4.创建新的项目
5.去各平台注册key
新浪微博:
a.证书签名需要个人证书导出项目时获取到
MD5 : 91:F0:5B:CE:67:58:F1:A1:E8:70:A4:F3:FA:5F:87:1B
证书格式为小写字母并不含:
91f05bce6758f1a1e870a4f3fa5f871b
6.sample里所有的图片以及values拷入当前新的项目:
此时需要修改 main_activity.xml and menu.xml 中跟 @String/ 有关的信息!
7.sample里asset里Sharesdk.xml拷入当前新的项目,并且修改指定内容
RedirectUrl:如果指定授权回调页,就填写回调页,如没有,就填写应用网址
8.需要把sample里mainifest中的权限拷入当前新的项目
9.sample里mainifest中的ShareSDKUIShell,activity注册到当前新的项目中,代码如下:
<activity
android:name="cn.sharesdk.framework.ShareSDKUIShell"
android:theme="@android:style/Theme.Translucent.NoTitleBar"android:configChanges="keyboardHidden|orientation|screenSize"android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>
10.拷入需要用到的jar包
必拷:mframework.jar
必拷:ShareSDK-Core-2.3.8jar
分享指定平台:
ShareSDK-XXX.jar
11.将onkeyshare包拷贝到当前项目中
分享步骤:
***************************
1.初始化ShareSDK
ShareSDK.init(this);
2.设置指定平台
Platform p=ShareSDK.getPlatform(XXX.NAME);
3.设置平台监听器
p.setPlatform
AcitonListener{
1.error
2.complete
3.cancel
}
4.进行授权
p.rauthorize();
5.重写平台监听器中的complete
获取某平台参数对象
Platform.ShareParams ps=
new XXX.ShareParams();
添加要分享的数据
ps.setText/setImageUrl/set..
分享
p.share(ps);
分享案例代码:
[html] view plaincopyprint?
package com.example.lovesharesdkdemo;
import java.util.HashMap;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.tencent.weibo.TencentWeibo;
public class MainActivity extends Activity {
private Platform platform;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//1 初始化SDK
ShareSDK.initSDK(getApplicationContext());
//2.设置指定平台
platform = ShareSDK.getPlatform(TencentWeibo.NAME);
//3 获取组件 注册事件
textView = (TextView) this.findViewById(R.id.buttton);
textView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//TOFO 分享SDK
getShareSDK();
}
private void getShareSDK() {
//3 给平台添加 listener
platform.setPlatformActionListener(new PlatformActionListener() {
@Override
public void onError(Platform arg0, int arg1, Throwable arg2) {
// TODO error useful
Log.i("error", "---error="+arg2.getLocalizedMessage());
}
@Override
public void onComplete(Platform arg0, int arg1, HashMap<String, Object> arg2) {
// TODO finished useful
//设置分享的参数:
TencentWeibo.ShareParams shareParams = new TencentWeibo.ShareParams();
shareParams.setText("美女的世界");
shareParams.setImageUrl("http://t12.baidu.com/it/u=750616964,1500186643&fm=59");
// 分享
platform.share(shareParams);
}
@Override
public void onCancel(Platform arg0, int arg1) {
// TODO cancel
ShareSDK
APP_KEY 219b1121fc68
腾讯微博
key 801517904
secret bfba83ae253c8f38dabe22c5fa4093bd
新浪微博
key 3815341537
secret f19fb8f89acc090716de7e3bde2e5f9e
包名+keySotre签名:91f05bce6758f1a1e870a4f3fa5f871b
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
准备阶段:
使用ShareSDK步骤
1. ShareSDK官网,创建应用 获取Key
2. ShareSDK官网,下载SDK
3. 使ShareSDK的DEMO正常运行
(类库:ShareSDK for Android
demo:ShareSDK for Android Sample)
4.创建新的项目
5.去各平台注册key
新浪微博:
a.证书签名需要个人证书导出项目时获取到
MD5 : 91:F0:5B:CE:67:58:F1:A1:E8:70:A4:F3:FA:5F:87:1B
证书格式为小写字母并不含:
91f05bce6758f1a1e870a4f3fa5f871b
6.sample里所有的图片以及values拷入当前新的项目:
此时需要修改 main_activity.xml and menu.xml 中跟 @String/ 有关的信息!
7.sample里asset里Sharesdk.xml拷入当前新的项目,并且修改指定内容
RedirectUrl:如果指定授权回调页,就填写回调页,如没有,就填写应用网址
8.需要把sample里mainifest中的权限拷入当前新的项目
9.sample里mainifest中的ShareSDKUIShell,activity注册到当前新的项目中,代码如下:
<activity
android:name="cn.sharesdk.framework.ShareSDKUIShell"
android:theme="@android:style/Theme.Translucent.NoTitleBar"android:configChanges="keyboardHidden|orientation|screenSize"android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>
10.拷入需要用到的jar包
必拷:mframework.jar
必拷:ShareSDK-Core-2.3.8jar
分享指定平台:
ShareSDK-XXX.jar
11.将onkeyshare包拷贝到当前项目中
分享步骤:
***************************
1.初始化ShareSDK
ShareSDK.init(this);
2.设置指定平台
Platform p=ShareSDK.getPlatform(XXX.NAME);
3.设置平台监听器
p.setPlatform
AcitonListener{
1.error
2.complete
3.cancel
}
4.进行授权
p.rauthorize();
5.重写平台监听器中的complete
获取某平台参数对象
Platform.ShareParams ps=
new XXX.ShareParams();
添加要分享的数据
ps.setText/setImageUrl/set..
分享
p.share(ps);
分享案例代码:
[html] view plaincopyprint?
package com.example.lovesharesdkdemo;
import java.util.HashMap;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.tencent.weibo.TencentWeibo;
public class MainActivity extends Activity {
private Platform platform;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//1 初始化SDK
ShareSDK.initSDK(getApplicationContext());
//2.设置指定平台
platform = ShareSDK.getPlatform(TencentWeibo.NAME);
//3 获取组件 注册事件
textView = (TextView) this.findViewById(R.id.buttton);
textView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//TOFO 分享SDK
getShareSDK();
}
private void getShareSDK() {
//3 给平台添加 listener
platform.setPlatformActionListener(new PlatformActionListener() {
@Override
public void onError(Platform arg0, int arg1, Throwable arg2) {
// TODO error useful
Log.i("error", "---error="+arg2.getLocalizedMessage());
}
@Override
public void onComplete(Platform arg0, int arg1, HashMap<String, Object> arg2) {
// TODO finished useful
//设置分享的参数:
TencentWeibo.ShareParams shareParams = new TencentWeibo.ShareParams();
shareParams.setText("美女的世界");
shareParams.setImageUrl("http://t12.baidu.com/it/u=750616964,1500186643&fm=59");
// 分享
platform.share(shareParams);
}
@Override
public void onCancel(Platform arg0, int arg1) {
// TODO cancel
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询