//分享 private UMSocialService mController; mController = UMServiceFactory.getUMSocialService("com.umeng.login"); //设置新浪SSO handler mController.getConfig().setSsoHandler(new SinaSsoHandler()); //参数1为当前Activity, 参数2为开发者在QQ互联申请的APP ID,参数3为开发者在QQ互联申请的APP kEY. UMQQSsoHandler qqSsoHandler = new UMQQSsoHandler(this, "100424468", "c7394704798a158208a74ab60104f0ba"); qqSsoHandler.addToSocialSDK(); //参数1为当前Activity, 参数2为开发者在QQ互联申请的APP ID,参数3为开发者在QQ互联申请的APP kEY. QZoneSsoHandler qZoneSsoHandler = new QZoneSsoHandler(this, "100424468", "c7394704798a158208a74ab60104f0ba"); qZoneSsoHandler.addToSocialSDK(); mController.openShare(InfoActivity.this, false);
Intent intent = getIntent(); String des = intent.getStringExtra("des"); Log.i("url", des); WebView web =(WebView) findViewById(R.id.webView); web.loadUrl(des); web.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // TODO Auto-generated method stub return super.shouldOverrideUrlLoading(view, url); } }); Button share = (Button) findViewById(R.id.share); Button qq = (Button) findViewById(R.id.qq); Button xinlang = (Button) findViewById(R.id.xinlang); Button qqkong = (Button) findViewById(R.id.qqkong); share.setOnClickListener(this); qq.setOnClickListener(this); xinlang.setOnClickListener(this); qqkong.setOnClickListener(this); switch (v.getId()) { case R.id.share: LinearLayout ll = (LinearLayout) findViewById(R.id.ll); ll.setVisibility(View.VISIBLE); break; case R.id.qq: shareData(SHARE_MEDIA.QQ); break; case R.id.xinlang: shareData(SHARE_MEDIA.SINA); break; case R.id.qqkong: shareData(SHARE_MEDIA.QZONE); break; default: break; } private void shareData(SHARE_MEDIA platform) {
mController.doOauthVerify(InfoActivity.this, platform, new UMAuthListener() { @Override public void onStart(SHARE_MEDIA platform) { Toast.makeText(InfoActivity.this, "授权开始", Toast.LENGTH_SHORT).show(); } @Override public void onError(SocializeException e, SHARE_MEDIA platform) { Toast.makeText(InfoActivity.this, "授权错误", Toast.LENGTH_SHORT).show(); } @Override public void onComplete(Bundle value, SHARE_MEDIA platform) { Toast.makeText(InfoActivity.this, "授权完成", Toast.LENGTH_SHORT).show(); //获取相关授权信息 mController.getPlatformInfo(InfoActivity.this, platform, new UMDataListener() { @Override public void onStart() { Toast.makeText(InfoActivity.this, "获取平台数据开始...", Toast.LENGTH_SHORT).show(); } @Override public void onComplete(int status, Map<String, Object> info) { if(status == 200 && info != null){ StringBuilder sb = new StringBuilder(); Set<String> keys = info.keySet(); for(String key : keys){ sb.append(key+"="+info.get(key).toString()+"\r\n"); } Log.d("TestData",sb.toString()); }else{ Log.d("TestData","发生错误:"+status); } } }); } @Override public void onCancel(SHARE_MEDIA platform) { Toast.makeText(InfoActivity.this, "授权取消", Toast.LENGTH_SHORT).show(); } } ); //设置分享内容 mController.setShareContent("友盟社会化组件(SDK)让移动应用快速整合社交分享功能, http://www.umeng.com/social"); //设置分享图片 mController.setShareMedia(new UMImage(InfoActivity.this, "http://www.umeng.com/images/pic/banner_module_social.png")); //直接分享 mController.directShare(InfoActivity.this, platform, new SnsPostListener() { @Override public void onStart() { Toast.makeText(InfoActivity.this, "分享开始",Toast.LENGTH_SHORT).show(); } @Override public void onComplete(SHARE_MEDIA platform,int eCode, SocializeEntity entity) { if(eCode == StatusCode.ST_CODE_SUCCESSED){ Toast.makeText(InfoActivity.this, "分享成功",Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(InfoActivity.this, "分享失败",Toast.LENGTH_SHORT).show(); } }
}); } | |