Android ShareSdk 分享错误解析

 

 

执行sharesdk 快捷分享,分享出错的提示

 

列出一些常用的快捷分享

 

share(message, null, SinaWeibo.NAME);
share(message, null, TencentWeibo.NAME);
share(share_content, null, Wechat.NAME);
share(share_content, null, WechatMoments.NAME);


 

 

 

// 新浪微博分享 腾讯微博等只需修改 NAME
		public void share(String text, String photopath, String sharename) {
			Platform.ShareParams sp = new SinaWeibo.ShareParams();
			sp.text = text;
			if (photopath!=null) {
				// sp.imagePath = "/mnt/sdcard/测试分享的图片.jpg";
				sp.imagePath = photopath;
			}
			Platform weibo = ShareSDK.getPlatform(context, sharename);
			// 设置分享事件回调
			weibo.setPlatformActionListener(new PlatformActionListener() {
				public void onError(Platform platform, int action, Throwable t) {
					// 操作失败的处理代码
//					Message m = handler.obtainMessage();
//					m.what = SHARE_FAIL;
//					TestShare.this.handler.sendMessage(m);
					
					Message msg =  handler.obtainMessage();
					msg.what = SHARE_FAIL;
					msg.arg1 = action;
					msg.obj = t;
					WeiBoShareActivity.this.handler.sendMessage(msg);
				}

				public void onComplete(Platform platform, int action,
						HashMap res) {
					// 操作成功的处理代码
					Message m = handler.obtainMessage();
					m.what = SHARE_SUCCESS;
					WeiBoShareActivity.this.handler.sendMessage(m);

					
				}

				public void onCancel(Platform platform, int action) {
					// 操作取消的处理代码
					Message m = handler.obtainMessage();
					m.what = SHARE_CANCEL;
					WeiBoShareActivity.this.handler.sendMessage(m);
				}
			});
			// 执行图文分享
			weibo.share(sp);
		}
		
		
		
		
		private Handler handler = new Handler() {
			/*
			 * (non-Javadoc)
			 * 
			 * @see android.os.Handler#handleMessage(android.os.Message)
			 */
			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				ProgressDlg.cancleDlg();
				switch (msg.what) {
		        case SHARE_SUCCESS:
					String successtext = getResources().getString(R.string.share_completed);
					EdjTools.showShortToast(successtext,WeiBoShareActivity.this);
		        	WeiBoShareActivity.this.finish();
                   
					break;
				case SHARE_FAIL:
					String failtext="";
					
					if (msg.obj instanceof WechatClientNotExistException) {
						failtext = getResources().getString(R.string.wechat_client_inavailable);
					}
					else if (msg.obj instanceof WechatTimelineNotSupportedException) {
						failtext = getResources().getString(R.string.wechat_client_inavailable);
					}
//					java.lang.Throwable: {"ret":5,"seqid":5950018181724704141,"detailerrinfo":
//					{"timestamp":1385346563,"proctime":41,"cmd":1472,"accesstoken":"","clientip":"219.143.8.242","apiname":"weibo.t.add","ret2":5,"appkey":"801400858","ret1":20,"ret4":3515057674,"ret3":75},"msg":"prevent duplicate publication","errcode":75}
					else if (msg.obj instanceof java.lang.Throwable &&  msg.obj.toString()!=null&&msg.obj.toString().contains("prevent duplicate publication")) {
					
						failtext = getResources().getString(R.string.prevent_duplicate);
					}else if(msg.obj.toString().contains("error")){
						failtext = getResources().getString(R.string.share_failed_error);

					}else {
						failtext = getResources().getString(R.string.share_failed);
					}
					EdjTools.showShortToast(failtext,WeiBoShareActivity.this);
					break;
				case SHARE_CANCEL:
					
					break;


				}
			}

		};


 

public class EdjTools {

	public static void showLongToast(String message, Context context) {
		Toast.makeText(context, message, Toast.LENGTH_LONG).show();
	}

	public static void showShortToast(String message, Context context) {
		Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
	}

}

 

 

  目前您的微信版本过低或未安装微信,需要安装微信才能使用
    Google+ 版本过低或者没有安装,需要升级或安装Google+才能使用!
    QQ 版本过低或者没有安装,需要升级或安装QQ才能使用!
    
    请稍后发送


关于第三个异常、腾讯微博连续发送同样的内容、并在网页删除该微博再次客户端分享时、出现分享失败

返回的内容在代码注释中

大意是:防止重发的发送   我加入了提示语句   "请稍后发送"

你可能感兴趣的:(【Android,基础】)