Java Code Examples for cn.sharesdk.framework.ShareSDK#initSDK()
The following examples show how to use
cn.sharesdk.framework.ShareSDK#initSDK() .
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: ThirdPartyLogin.java From ThirdPartyLoginDemo with MIT License | 6 votes |
private void initSDK(Context context) { //初始化sharesdk,具体集成步骤请看文档: //http://wiki.mob.com/Android_%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97 ShareSDK.initSDK(context); //短信验证初始化,具体集成步骤看集成文档: //http://wiki.mob.com/Android_%E7%9F%AD%E4%BF%A1SDK%E9%9B%86%E6%88%90%E6%96%87%E6%A1%A3 SMSSDK.initSDK(context, smssdkAppkey, smssdkAppSecret); EventHandler eh = new EventHandler(){ public void afterEvent(int event, int result, Object data) { Message msg = new Message(); msg.arg1 = event; msg.arg2 = result; msg.obj = data; handler.sendMessage(msg); } }; //注册短信验证的监听 SMSSDK.registerEventHandler(eh); }
Example 2
Source File: AfterRegistShareDialogActivity.java From Social with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.after_regist_share_dialog_activity_layout); username = getIntent().getStringExtra("username"); ShareSDK.initSDK(this); handler = new Handler(){ @Override public void handleMessage(Message msg) { switch (msg.what){ case OkhttpUtil.MESSAGE_GET_SHARE_INFO: handleGetShareInfo(msg); break; } } }; initView(); }
Example 3
Source File: DetailActivity.java From POCenter with MIT License | 6 votes |
private void showShare() { ShareSDK.initSDK(this); OnekeyShare oks = new OnekeyShare(); //关闭sso授权 oks.disableSSOWhenAuthorize(); // title标题,印象笔记、邮箱、信息、微信、人人网和QQ空间等使用 oks.setTitle(title); // titleUrl是标题的网络链接,QQ和QQ空间等使用 oks.setTitleUrl(url); // text是分享文本,所有平台都需要这个字段 oks.setText(description); // imagePath是图片的本地路径,Linked-In以外的平台都支持此参数 //oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片 // url仅在微信(包括好友和朋友圈)中使用 oks.setUrl(url); // site是分享此内容的网站名称,仅在QQ空间使用 oks.setSite(getString(R.string.app_name)); // siteUrl是分享此内容的网站地址,仅在QQ空间使用 oks.setSiteUrl("https://www.ittianyu.com"); // 启动分享GUI oks.show(this); }
Example 4
Source File: OnekeyShare.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void show(Context context) { HashMap<String, Object> shareParamsMap = new HashMap<String, Object>(); shareParamsMap.putAll(params); ShareSDK.initSDK(context); // 打开分享菜单的统计 ShareSDK.logDemoEvent(1, null); int iTheme = 0; try { iTheme = R.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); }
Example 5
Source File: OnekeyShare.java From LQRWeChat with MIT License | 5 votes |
@SuppressWarnings("unchecked") public void show(Context context) { HashMap<String, Object> shareParamsMap = new HashMap<String, Object>(); shareParamsMap.putAll(params); MobSDK.init(context.getApplicationContext()); ShareSDK.initSDK(context); // 打开分享菜单的统计 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 6
Source File: LevelTop.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
private void beforeLogin() { try { ShareSDK.initSDK(getContext()); } catch (Exception ex) { } BaseActivity.soundMgr.select(); }
Example 7
Source File: BaoKanApp.java From BaoKanAndroid with MIT License | 5 votes |
@Override public void onCreate() { super.onCreate(); app = this; // 存放所有activity的集合 mActivityList = new ArrayList<>(); // 渐进式图片 ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this) .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig()) .build(); Fresco.initialize(this, config); // 初始化app异常处理器 - 打包的时候开启 CrashHandler handler = CrashHandler.getInstance(); handler.init(getApplicationContext()); // OkHttpClient okHttpClient = new OkHttpClient.Builder() // .connectTimeout(10000L, TimeUnit.MILLISECONDS) // .readTimeout(10000L, TimeUnit.MILLISECONDS) // //其他配置 // .build(); // OkHttpUtils.initClient(okHttpClient); // 初始化ShareSDK ShareSDK.initSDK(this); }
Example 8
Source File: ShareUtil.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
/** * 分享文字和图片 * * @param msg * 文字信息 * @param view * 截图的view */ public void shareMsgView(String msg, View view) { ShareSDK.initSDK(context); OnekeyShare oks = new OnekeyShare(); oks.setText(msg); oks.setViewToShare(view); showShare(oks); }
Example 9
Source File: MessageDetailActivity.java From Mobike with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_message_detail); ButterKnife.bind(this); getData(); initToolbar(); initWebView(); ShareSDK.initSDK(this); }
Example 10
Source File: OnekeyShare.java From BaoKanAndroid with MIT License | 5 votes |
@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 11
Source File: ShareUtil.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
/** * 分享截图 * * @param view * 截图的view */ public void shareView(View view) { ShareSDK.initSDK(context); OnekeyShare oks = new OnekeyShare(); oks.setViewToShare(view); showShare(oks); }
Example 12
Source File: OnekeyShare.java From LiuAGeAndroid with MIT License | 5 votes |
@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 13
Source File: UserDetailActivity.java From MyHearts with Apache License 2.0 | 5 votes |
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(mUserDatas.getNickname()); // titleUrl是标题的网络链接,仅在人人网和QQ空间使用 oks.setTitleUrl("https://github.com/wuyinlei/MyHearts"); // text是分享文本,所有平台都需要这个字段 oks.setText(mUserDatas.getHobby()); //分享网络图片,新浪微博分享网络图片需要通过审核后申请高级写入接口,否则请注释掉测试新浪微博 oks.setImageUrl(mUserDatas.getAvatar()); // imagePath是图片的本地路径,Linked-In以外的平台都支持此参数 //oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片 // url仅在微信(包括好友和朋友圈)中使用 oks.setUrl("http://sharesdk.cn"); // comment是我对这条分享的评论,仅在人人网和QQ空间使用 oks.setComment(mUserDatas.getHobby()); // site是分享此内容的网站名称,仅在QQ空间使用 oks.setSite("GitHub"); // siteUrl是分享此内容的网站地址,仅在QQ空间使用 oks.setSiteUrl("https://github.com/wuyinlei/MyHearts"); // 启动分享GUI oks.show(this); }
Example 14
Source File: AuthPageAty.java From Huochexing12306 with Apache License 2.0 | 5 votes |
private void initViews() { ShareSDK.initSDK(this); lvPlats.setSelector(new ColorDrawable()); mAdapter = new AuthAdapter(this); lvPlats.setAdapter(mAdapter); lvPlats.setOnItemClickListener(mAdapter); }
Example 15
Source File: ShareContentAty.java From Huochexing12306 with Apache License 2.0 | 5 votes |
private void showShare(String shareText) { ShareSDK.initSDK(this); OnekeyShare oks = new OnekeyShare(); //关闭sso授权 oks.disableSSOWhenAuthorize(); // 分享时Notification的图标和文字 oks.setNotification(R.drawable.ic_launcher, getString(R.string.app_name)); // title标题,印象笔记、邮箱、信息、微信、人人网和QQ空间使用 oks.setTitle("火车行"); // titleUrl是标题的网络链接,仅在人人网和QQ空间使用 oks.setTitleUrl(WEB_SITE); // text是分享文本,所有平台都需要这个字段 oks.setText(shareText); // imagePath是图片的本地路径,Linked-In以外的平台都支持此参数 oks.setImagePath(imageDataPath); // url仅在微信(包括好友和朋友圈)中使用 oks.setUrl(WEB_SITE); // comment是我对这条分享的评论,仅在人人网和QQ空间使用 oks.setComment(shareText); // site是分享此内容的网站名称,仅在QQ空间使用 oks.setSite(getString(R.string.app_name)); // siteUrl是分享此内容的网站地址,仅在QQ空间使用 oks.setSiteUrl(WEB_SITE); // 启动分享GUI oks.show(this); }
Example 16
Source File: OnekeyShare.java From POCenter with MIT License | 5 votes |
@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 17
Source File: OnekeyShare.java From AndroidLinkup with GNU General Public License v2.0 | 4 votes |
public void show(Context context) { ShareSDK.initSDK(context); super.show(context, null); }
Example 18
Source File: LoginAty.java From Huochexing12306 with Apache License 2.0 | 4 votes |
private void initViews() { btnFindPwd = (Button) findViewById(R.id.login_btnFindPwd); btnFindPwd.setOnClickListener(this); Button btnSkip = (Button)findViewById(R.id.login_btnSkip); btnSkip.setOnClickListener(this); btnLogin = (Button) findViewById(R.id.login_btnLogin); btnLogin.setOnClickListener(this); btnRegister = (Button) findViewById(R.id.login_btnUserRegister); btnRegister.setOnClickListener(this); etUserName = (EditText) findViewById(R.id.login_etUserName); etPwd = (EditText) findViewById(R.id.login_etPwd); ivQQ = (ImageView)findViewById(R.id.login_ivQQ); ivQQ.setOnClickListener(this); ivSinaWeibo = (ImageView)findViewById(R.id.login_ivSinaWeibo); ivSinaWeibo.setOnClickListener(this); ivDouban = (ImageView)findViewById(R.id.login_ivDouban); ivDouban.setOnClickListener(this); ivGoogleplus = (ImageView)findViewById(R.id.login_ivGoogleplus); ivGoogleplus.setOnClickListener(this); ivWeichat = (ImageView)findViewById(R.id.login_ivWeichat); ivWeichat.setOnClickListener(this); ivYixin = (ImageView)findViewById(R.id.login_ivYixin); ivYixin.setOnClickListener(this); ivRenren = (ImageView)findViewById(R.id.login_ivRenren); ivRenren.setOnClickListener(this); ivLine = (ImageView)findViewById(R.id.login_ivLine); ivLine.setOnClickListener(this); ShareSDK.initSDK(this); if (!userSP.isThirdPartyLogin()){ etUserName.setText(userSP.getUsername()); } if (setSP.isFirstUse()){ mIsFirstUseLogin = true; setSP.setFirstUse(false); btnSkip.setVisibility(View.VISIBLE); }else{ btnSkip.setVisibility(View.GONE); } }
Example 19
Source File: SocialPlatform.java From AnimeTaste with MIT License | 4 votes |
public SocialPlatform(Context context) { ShareSDK.initSDK(context); mContext = context; mSharedPreferences = PreferenceManager .getDefaultSharedPreferences(mContext); }
Example 20
Source File: ShareSDKUtils.java From BigApp_Discuz_Android with Apache License 2.0 | 4 votes |
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); }