cn.sharesdk.framework.ShareSDK Java Examples

The following examples show how to use cn.sharesdk.framework.ShareSDK. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlatformPage.java    From LQRWeChat with MIT License 6 votes vote down vote up
public final void showEditPage(final Platform platform) {
	beforeFinish = new Runnable() {
		public void run() {
			boolean isSilent = isSilent();
			boolean isCustomPlatform = platform instanceof CustomPlatform;
			boolean isUseClientToShare = isUseClientToShare(platform);
			if (isSilent || isCustomPlatform || isUseClientToShare) {
				shareSilently(platform);
			} else {
				ShareParams sp = formateShareData(platform);
				if (sp != null) {
					// 编辑分享内容的统计
					ShareSDK.logDemoEvent(3, null);
					if (getCustomizeCallback() != null) {
						getCustomizeCallback().onShare(platform, sp);
					}
					impl.showEditPage(activity, platform, sp);
				}
			}
		}
	};
	finish();
}
 
Example #2
Source File: UserBean.java    From LiuAGeAndroid with MIT License 6 votes vote down vote up
/**
 * 从本地更新用户信息 - 登录成功后保存到偏好设置
 */
public void updateUserInfoFromLocal() {

    // 移除第三方授权
    Platform wechat = ShareSDK.getPlatform(Wechat.NAME);
    if (wechat.isAuthValid()) {
        wechat.removeAccount(true);
    }
    Platform qq = ShareSDK.getPlatform(QQ.NAME);
    if (qq.isAuthValid()) {
        qq.removeAccount(true);
    }

    // 内存缓存
    UserBean.userAccount = this;
    // 磁盘缓存
    encode();
}
 
Example #3
Source File: PlatformGridView.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private void init(final Context context) {
	calPageSize();
	setOrientation(VERTICAL);

	pager = new ViewPagerClassic(context);
	disableOverScrollMode(pager);
	pager.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	addView(pager);

	// in order to have a better UI effect, opening a thread request the list of platforms
	new Thread() {
		public void run() {
			try {
				platformList = ShareSDK.getPlatformList();
				if (platformList == null) {
					platformList = new Platform[0];
				}
				UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
			} catch (Throwable t) {
				t.printStackTrace();
			}
		}
	}.start();
}
 
Example #4
Source File: PlatformGridView.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
private void init(final Context context) {
	calPageSize();
	setOrientation(VERTICAL);

	pager = new ViewPagerClassic(context);
	disableOverScrollMode(pager);
	pager.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	addView(pager);

	// 为了更好的ui效果,开启子线程获取平台列表
	new Thread() {
		public void run() {
			platformList = ShareSDK.getPlatformList();
			if (platformList == null) {
				platformList = new Platform[0];
			}
			UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
		}
	}.start();
}
 
Example #5
Source File: PlatformPage.java    From enjoyshop with Apache License 2.0 6 votes vote down vote up
protected ArrayList<Object> collectCells() {
    ArrayList<Object> cells = new ArrayList<Object>();

    Platform[] platforms = ShareSDK.getPlatformList();
    if (platforms == null) {
        platforms = new Platform[0];
    }
    HashMap<String, String> hides = getHiddenPlatforms();
    if (hides == null) {
        hides = new HashMap<String, String>();
    }
    for (Platform p : platforms) {
        if (!hides.containsKey(p.getName())) {
            cells.add(p);
        }
    }

    ArrayList<CustomerLogo> customers = getCustomerLogos();
    if (customers != null && customers.size() > 0) {
        cells.addAll(customers);
    }

    return cells;
}
 
Example #6
Source File: OnekeyShareThemeImpl.java    From enjoyshop with Apache License 2.0 6 votes vote down vote up
public final void show(Context context) {
	this.context = context;

	// 显示方式是由platform和silent两个字段控制的
	// 如果platform设置了,则无须显示九宫格,否则都会显示;
	// 如果silent为true,表示不进入编辑页面,否则会进入。
	if (shareParamsMap.containsKey("platform")) {
		String name = String.valueOf(shareParamsMap.get("platform"));
		Platform platform = ShareSDK.getPlatform(name);
		boolean isCustomPlatform = platform instanceof CustomPlatform;
		boolean isUseClientToShare = isUseClientToShare(platform);
		if (silent || isCustomPlatform || isUseClientToShare) {
			shareSilently(platform);
		} else {
			prepareForEditPage(platform);
		}
	} else {
		showPlatformPage(context);
	}
}
 
Example #7
Source File: PlatformPage.java    From BaoKanAndroid with MIT License 6 votes vote down vote up
protected ArrayList<Object> collectCells() {
	ArrayList<Object> cells = new ArrayList<Object>();

	Platform[] platforms = ShareSDK.getPlatformList();
	if (platforms == null) {
		platforms = new Platform[0];
	}
	HashMap<String, String> hides = getHiddenPlatforms();
	if (hides == null) {
		hides = new HashMap<String, String>();
	}
	for (Platform p : platforms) {
		if (!hides.containsKey(p.getName())) {
			cells.add(p);
		}
	}

	ArrayList<CustomerLogo> customers = getCustomerLogos();
	if (customers != null && customers.size() > 0) {
		cells.addAll(customers);
	}

	return cells;
}
 
Example #8
Source File: OnekeyShareThemeImpl.java    From LiuAGeAndroid with MIT License 6 votes vote down vote up
public final void show(Context context) {
	this.context = context;

	// 显示方式是由platform和silent两个字段控制的
	// 如果platform设置了,则无须显示九宫格,否则都会显示;
	// 如果silent为true,表示不进入编辑页面,否则会进入。
	if (shareParamsMap.containsKey("platform")) {
		String name = String.valueOf(shareParamsMap.get("platform"));
		Platform platform = ShareSDK.getPlatform(name);
		boolean isCustomPlatform = platform instanceof CustomPlatform;
		boolean isUseClientToShare = isUseClientToShare(platform);
		if (silent || isCustomPlatform || isUseClientToShare) {
			shareSilently(platform);
		} else {
			prepareForEditPage(platform);
		}
	} else {
		showPlatformPage(context);
	}
}
 
Example #9
Source File: PlatformGridView.java    From AndroidLinkup with GNU General Public License v2.0 6 votes vote down vote up
private void init(final Context context) {
	calPageSize();
	setOrientation(VERTICAL);

	pager = new ViewPagerClassic(context);
	disableOverScrollMode(pager);
	pager.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	addView(pager);

	// 为了更好的ui效果,开启子线程获取平台列表
	new Thread() {
		public void run() {
			platformList = ShareSDK.getPlatformList();
			if (platformList == null) {
				platformList = new Platform[0];
			}
			UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
		}
	}.start();
}
 
Example #10
Source File: WeiboShare.java    From ShareSDK-for-Android with MIT License 6 votes vote down vote up
/**
 * 新浪linkcard分享
 **/
public void shareLinkCard() {
	JSONObject jsonObject = new JSONObject();
	try {
		jsonObject.put("url", "https://t3.ftcdn.net/jpg/02/01/25/00/240_F_201250053_xMFe9Hax6w01gOiinRLEPX0Wt1zGCzYz.jpg");
		jsonObject.put("width", 120);
		jsonObject.put("height", 120);
	} catch (JSONException e) {
		e.printStackTrace();
	}

	Platform platform = ShareSDK.getPlatform(SinaWeibo.NAME);
	Platform.ShareParams sp = new Platform.ShareParams();
	sp.setText("MobSDK 只为最优质的服务");
	sp.setLcCreateAt("2019-01-24");
	sp.setLcDisplayName("Mob-全球领先的第三方服务商");
	sp.setLcImage(jsonObject);
	sp.setLcSummary("不止是SDK");
	sp.setLcUrl("http://www.mob.com/");
	sp.setLcObjectType("webpage");
	platform.setPlatformActionListener(platformActionListener);
	platform.share(sp);
}
 
Example #11
Source File: OnekeyShareThemeImpl.java    From BaoKanAndroid with MIT License 6 votes vote down vote up
public final void show(Context context) {
	this.context = context;

	// 显示方式是由platform和silent两个字段控制的
	// 如果platform设置了,则无须显示九宫格,否则都会显示;
	// 如果silent为true,表示不进入编辑页面,否则会进入。
	if (shareParamsMap.containsKey("platform")) {
		String name = String.valueOf(shareParamsMap.get("platform"));
		Platform platform = ShareSDK.getPlatform(name);
		boolean isCustomPlatform = platform instanceof CustomPlatform;
		boolean isUseClientToShare = isUseClientToShare(platform);
		if (silent || isCustomPlatform || isUseClientToShare) {
			shareSilently(platform);
		} else {
			prepareForEditPage(platform);
		}
	} else {
		showPlatformPage(context);
	}
}
 
Example #12
Source File: PlatformPage.java    From Mobike with Apache License 2.0 6 votes vote down vote up
public final void showEditPage(final Platform platform) {
	beforeFinish = new Runnable() {
		public void run() {
			boolean isSilent = isSilent();
			boolean isCustomPlatform = platform instanceof CustomPlatform;
			boolean isUseClientToShare = isUseClientToShare(platform);
			if (isSilent || isCustomPlatform || isUseClientToShare) {
				shareSilently(platform);
			} else {
				ShareParams sp = formateShareData(platform);
				if (sp != null) {
					// 编辑分享内容的统计
					ShareSDK.logDemoEvent(3, null);
					if (getCustomizeCallback() != null) {
						getCustomizeCallback().onShare(platform, sp);
					}
					impl.showEditPage(activity, platform, sp);
				}
			}
		}
	};
	finish();
}
 
Example #13
Source File: OnekeyShareThemeImpl.java    From Mobike with Apache License 2.0 6 votes vote down vote up
public final void show(Context context) {
	this.context = context;

	// 显示方式是由platform和silent两个字段控制的
	// 如果platform设置了,则无须显示九宫格,否则都会显示;
	// 如果silent为true,表示不进入编辑页面,否则会进入。
	if (shareParamsMap.containsKey("platform")) {
		String name = String.valueOf(shareParamsMap.get("platform"));
		Platform platform = ShareSDK.getPlatform(name);
		boolean isCustomPlatform = platform instanceof CustomPlatform;
		boolean isUseClientToShare = isUseClientToShare(platform);
		if (silent || isCustomPlatform || isUseClientToShare) {
			shareSilently(platform);
		} else {
			prepareForEditPage(platform);
		}
	} else {
		showPlatformPage(context);
	}
}
 
Example #14
Source File: FacebookMessengerShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(FacebookMessenger.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setImageArray(ResourcesManager.getInstace(MobSDK.getContext()).randomPic());
	shareParams.setShareType(Platform.SHARE_IMAGE);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #15
Source File: YouDaoShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareText(){
	Platform platform = ShareSDK.getPlatform(YouDao.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(LINK_TEXT);
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setUrl(LINK_URL);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #16
Source File: OnekeyShareThemeImpl.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public final void onCancel(Platform platform, int action) {
	Message msg = new Message();
	msg.arg1 = 3;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);

	// 分享失败的统计
	ShareSDK.logDemoEvent(5, platform);
}
 
Example #17
Source File: YixinShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareText() {
	Platform platform = ShareSDK.getPlatform(Yixin.NAME);
	Platform.ShareParams shareParams = new Platform.ShareParams();
	shareParams.setText("texttestettt");
	shareParams.setTitle("titletsdfsdf");
	shareParams.setShareType(Platform.SHARE_TEXT);
	shareParams.setScence(0);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #18
Source File: OnekeyShareThemeImpl.java    From GithubApp with Apache License 2.0 5 votes vote down vote up
public final void onCancel(Platform platform, int action) {
	Message msg = new Message();
	msg.arg1 = 3;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);

	// 分享失败的统计
	ShareSDK.logDemoEvent(5, platform);
}
 
Example #19
Source File: FacebookShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareApps(){
	Platform platform = ShareSDK.getPlatform(Facebook.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setShareType(Platform.SHARE_APPS);
	shareParams.setUrl("https://fb.me/1654865544566386");//Facebook开放平台创建后得到的短链接
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #20
Source File: YixinMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareText(){
	Platform platform = ShareSDK.getPlatform(YixinMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText("texttestettt");
	shareParams.setTitle("titletsdfsdf");
	shareParams.setImageUrl("https://t3.ftcdn.net/jpg/02/01/25/00/240_F_201250053_xMFe9Hax6w01gOiinRLEPX0Wt1zGCzYz.jpg");
	shareParams.setShareType(Platform.SHARE_TEXT);
	shareParams.setScence(1);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #21
Source File: PocketShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareWebPager(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(Pocket.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setUrl(ResourcesManager.getInstace(MobSDK.getContext()).getUrl());
	shareParams.setTags(ResourcesManager.TAGS);
	shareParams.setExtInfo(ResourcesManager.EXT_INFO);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #22
Source File: MeipaiShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(Meipai.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	shareParams.setImageArray(ResourcesManager.getInstace(MobSDK.getContext()).randomPic());
	shareParams.setShareType(Platform.SHARE_IMAGE);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #23
Source File: MainActivity.java    From ShareSDKShareDifMsgDemo-Android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	ShareSDK.initSDK(this);
	//初始化sharesdk,具体集成步骤请看文档:
	//http://wiki.mob.com/Android_%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97
	
	findViewById(R.id.btn_sms).setOnClickListener(this);
	findViewById(R.id.btn_sina).setOnClickListener(this);
	findViewById(R.id.btn_tencent).setOnClickListener(this);
	findViewById(R.id.btn_wechatmoment).setOnClickListener(this);
	
}
 
Example #24
Source File: OnekeyShareThemeImpl.java    From BaoKanAndroid with MIT License 5 votes vote down vote up
private void prepareForEditPage(Platform platform) {
	if (formateShareData(platform)) {
		ShareParams sp = shareDataToShareParams(platform);
		if (sp != null) {
			// 编辑分享内容的统计
			ShareSDK.logDemoEvent(3, null);
			if (customizeCallback != null) {
				customizeCallback.onShare(platform, sp);
			}
			showEditPage(context, platform, sp);
		}
	}
}
 
Example #25
Source File: OnekeyShare.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void show(Context context) {
	HashMap<String, Object> shareParamsMap = new HashMap<String, Object>();
	shareParamsMap.putAll(params);

	ShareSDK.initSDK(context.getApplicationContext());

	// 打开分享菜单的统计
	ShareSDK.logDemoEvent(1, null);

	int iTheme = 0;
	try {
		iTheme = ResHelper.parseInt(String.valueOf(shareParamsMap.remove("theme")));
	} catch (Throwable t) {}
	OnekeyShareTheme theme = OnekeyShareTheme.fromValue(iTheme);
	OnekeyShareThemeImpl themeImpl = theme.getImpl();

	themeImpl.setShareParamsMap(shareParamsMap);
	themeImpl.setDialogMode(shareParamsMap.containsKey("dialogMode") ? ((Boolean) shareParamsMap.remove("dialogMode")) : false);
	themeImpl.setSilent(shareParamsMap.containsKey("silent") ? ((Boolean) shareParamsMap.remove("silent")) : false);
	themeImpl.setCustomerLogos((ArrayList<CustomerLogo>) shareParamsMap.remove("customers"));
	themeImpl.setHiddenPlatforms((HashMap<String, String>) shareParamsMap.remove("hiddenPlatforms"));
	themeImpl.setPlatformActionListener((PlatformActionListener) shareParamsMap.remove("callback"));
	themeImpl.setShareContentCustomizeCallback((ShareContentCustomizeCallback) shareParamsMap.remove("customizeCallback"));
	if (shareParamsMap.containsKey("disableSSO") ? ((Boolean) shareParamsMap.remove("disableSSO")) : false) {
		themeImpl.disableSSO();
	}

	themeImpl.show(context.getApplicationContext());
}
 
Example #26
Source File: TwitterShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareVideo(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(Twitter.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());
	shareParams.setShareType(Platform.SHARE_VIDEO);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #27
Source File: KakaoTalkShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareText(){
	Platform platform = ShareSDK.getPlatform(KakaoTalk.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(LINK_TEXT);
	shareParams.setSite(ResourcesManager.getInstace(MobSDK.getContext()).getSite());
	shareParams.setUrl(LINK_URL);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #28
Source File: SohuMicroBlogShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform("SohuMicroBlog");
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #29
Source File: NewsDetailActivity.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.ib_news_detail_bottom_bar_back:
            finish();
            break;
        case R.id.ib_news_detail_bottom_bar_edit:
            showCommentDialog();
            break;
        case R.id.ib_news_detail_bottom_bar_font:
            showSetFontDialog();
            break;
        case R.id.ib_news_detail_bottom_bar_collection:
            collectArticle();
            break;
        case R.id.ib_news_detail_bottom_bar_share:
            // 弹出分享ui
            showShare(null);
            break;
        case R.id.ll_article_content_share_qq:
            // qq分享
            showShare(ShareSDK.getPlatform(QQ.NAME).getName());
            break;
        case R.id.ll_article_content_share_weixin:
            // 微信分享
            showShare(ShareSDK.getPlatform(Wechat.NAME).getName());
            break;
        case R.id.ll_article_content_share_pyq:
            // 朋友圈分享
            showShare(ShareSDK.getPlatform(WechatMoments.NAME).getName());
            break;
        case R.id.iv_news_detail_ad_image:
            didTappedAdImageView();
            break;
    }
}
 
Example #30
Source File: ShortMessageShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareVideo(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(ShortMessage.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());
	shareParams.setShareType(Platform.SHARE_VIDEO);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}