Java Code Examples for cn.sharesdk.onekeyshare.OnekeyShare#setShareContentCustomizeCallback()

The following examples show how to use cn.sharesdk.onekeyshare.OnekeyShare#setShareContentCustomizeCallback() . 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: MainActivity.java    From ShareSDKShareDifMsgDemo-Android with MIT License 6 votes vote down vote up
private void showShare(boolean silent, String platform){
	final OnekeyShare oks = new OnekeyShare();
	oks.setNotification(R.drawable.ic_launcher, this.getString(R.string.app_name));
	//不同平台的分享参数,请看文档
	//http://wiki.mob.com/Android_%E4%B8%8D%E5%90%8C%E5%B9%B3%E5%8F%B0%E5%88%86%E4%BA%AB%E5%86%85%E5%AE%B9%E7%9A%84%E8%AF%A6%E7%BB%86%E8%AF%B4%E6%98%8E
	String text = this.getString(R.string.share_title) + "http://www.mob.com";
	oks.setTitle("share title");		
	oks.setText(text);
	//oks.setSilent(silent);
	oks.setDialogMode();
	oks.disableSSOWhenAuthorize();
	if (platform != null) {
		oks.setPlatform(platform);
	}
	// 去自定义不同平台的字段内容
	// http://wiki.mob.com/Android_%E5%BF%AB%E6%8D%B7%E5%88%86%E4%BA%AB#.E4.B8.BA.E4.B8.8D.E5.90.8C.E5.B9.B3.E5.8F.B0.E5.AE.9A.E4.B9.89.E5.B7.AE.E5.88.AB.E5.8C.96.E5.88.86.E4.BA.AB.E5.86.85.E5.AE.B9
	oks.setShareContentCustomizeCallback(new ShareContentCustomizeDemo());
	oks.show(this);
}
 
Example 2
Source File: WeatherActivity.java    From PoetryWeather with Apache License 2.0 5 votes vote down vote up
private void showShare() {
    OnekeyShare oks = new OnekeyShare();
    //关闭sso授权
    oks.disableSSOWhenAuthorize();

    // title标题,微信、QQ和QQ空间等平台使用
    oks.setTitle(getString(R.string.shareName));
    // titleUrl QQ和QQ空间跳转链接
    oks.setTitleUrl("http://hzmeurasia.cn");
    // text是分享文本,所有平台都需要这个字段
    oks.setText("我是分享文本");
    // imagePath是图片的本地路径,Linked-In以外的平台都支持此参数
    //确保SDcard下面存在此张图片
    oks.setImagePath(Environment.getExternalStorageDirectory().getAbsolutePath()+"/ScreenPoetryWeather.png");
    // url在微信、微博,Facebook等平台中使用
    oks.setShareContentCustomizeCallback(new ShareContentCustomizeCallback() {
        @Override
        public void onShare(Platform platform, Platform.ShareParams shareParams) {
            if (platform.getName().equalsIgnoreCase(QQ.NAME)) {
                shareParams.setText(null);
                shareParams.setTitle(null);
                shareParams.setTitleUrl(null);
                shareParams.setImagePath(Environment.getExternalStorageDirectory().getAbsolutePath()+"/ScreenPoetryWeather.png");
            }
        }
    });
    oks.setUrl("http://hzmeurasia.cn");
    // 启动分享GUI
    oks.show(this);
}
 
Example 3
Source File: ShareSDKUtils.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
public static void share(ActionBarActivity activity, String title, String text, String comment
            , String titleUrl, String siteName, String siteUrl, String imagePath, String imageUrl, final String weiboAt) {
        ShareSDK.initSDK(activity);
        final OnekeyShare oks = new OnekeyShare();

        title = HtmlUtils.delHTMLTag(title);
        text = HtmlUtils.delHTMLTag(text);

        //关闭sso授权
        oks.disableSSOWhenAuthorize();

        // 分享时Notification的图标和文字  2.5.9以后的版本不调用此方法
        //oks.setNotification(R.drawable.ic_launcher, getString(R.string.app_name));
        // title标题,印象笔记、邮箱、信息、微信、人人网和QQ空间使用
        oks.setTitle(title);
        // titleUrl是标题的网络链接,仅在人人网和QQ空间使用
        oks.setTitleUrl(titleUrl);
        // text是分享文本,所有平台都需要这个字段
        oks.setText(text);

        // imagePath是图片的本地路径,Linked-In以外的平台都支持此参数
        if (imagePath != null && imagePath.length() > 0) {
            oks.setImagePath(imagePath);//确保SDcard下面存在此张图片
        } else
            oks.setImageUrl(imageUrl);

        // url仅在微信(包括好友和朋友圈)中使用
        oks.setUrl(titleUrl);
        // comment是我对这条分享的评论,仅在人人网和QQ空间使用
        oks.setComment(comment);
        // site是分享此内容的网站名称,仅在QQ空间使用
        oks.setSite(siteName);
        // siteUrl是分享此内容的网站地址,仅在QQ空间使用
        oks.setSiteUrl(siteUrl);


        oks.setOnShareButtonClickListener(new PlatformListFakeActivity.OnShareButtonClickListener() {
            @Override
            public void onClick(View v, List<Object> checkPlatforms) {

                ZogUtils.printLog(ShareSDKUtils.class, "v:" + v + " checkPlatforms:" + checkPlatforms + " " + checkPlatforms.size());
                if (checkPlatforms != null && !checkPlatforms.isEmpty() && (checkPlatforms.get(0) instanceof SinaWeibo)) {
//                    String shareContent = oks.getTitle() + " " + oks.getTitleUrl() + ((weiboAt != null && weiboAt.length() > 0) ? " @" + weiboAt : "");

                    String shareContent = oks.getTitle();
                    oks.setText(shareContent);

                    oks.setImageUrl(null);


                }


            }
        });
        ShareContentCustomizeDemo  shareContentCustomizeDemo =  new ShareContentCustomizeDemo();
        shareContentCustomizeDemo.setSinaWeiboAt(weiboAt);
        oks.setShareContentCustomizeCallback(shareContentCustomizeDemo);

        // 启动分享GUI
        oks.show(activity);

    }