shareSDK分享_登陆

来源:互联网 发布:网络维护外包服务方案 编辑:程序博客网 时间:2024/05/16 23:48

//分享

public void onclick(View v){


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("张良分享");

// titleUrl是标题的网络链接,仅在人人网和QQ空间使用

oks.setTitleUrl("http://sharesdk.cn");

// text是分享文本,所有平台都需要这个字段

oks.setText("我是分享文本");

// imagePath是图片的本地路径,Linked-In以外的平台都支持此参数

//oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片

// url仅在微信(包括好友和朋友圈)中使用

oks.setUrl("http://sharesdk.cn");

// comment是我对这条分享的评论,仅在人人网和QQ空间使用

//oks.setComment("我是测试评论文本");

// site是分享此内容的网站名称,仅在QQ空间使用

oks.setSite("你好哈哈哈");

// siteUrl是分享此内容的网站地址,仅在QQ空间使用

oks.setSiteUrl("http://sharesdk.cn");


// 启动分享GUI

oks.show(this);

}

//登录

public void login(View v){

Platform platform11 = ShareSDK.getPlatform(QQ.NAME);

//platform11.SSOSetting(true);

platform11.authorize();

platform11.showUser(null);//必须要加的要不然不行!这个才是授权的!

tm = (TelephonyManager) MainActivity.this.getSystemService(TELEPHONY_SERVICE);

imi = tm.getDeviceId();

platform11.setPlatformActionListener(new PlatformActionListener() {

@Override

public void onError(Platform platform11, int arg1, Throwable arg2) {

//弹出失败窗口

}

@SuppressLint("SimpleDateFormat") @Override

public void onComplete(Platform platform11, int arg1, HashMap<String, Object> arg2) {


System.out.println("登录成功。。。。");





/*String userId = platform11.getDb().getUserId();

//头像

String path=platform11.getDb().getUserIcon();

//用户名

String userName = platform11.getDb().getUserName();

String token = platform11.getDb().getToken();

long expiresTime = platform11.getDb().getExpiresTime();

SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm");

System.out.println("userId "+userId);

System.out.println("userName "+userName);

System.out.println("token "+token);

System.out.println("expiresTime "+sdf3.format(expiresTime));

HttpUties ht=new HttpUties();

ht.UplodePhotos(1+"", userId+"", userName+"", token+"", expiresTime+"", imi+"");*/

}

@Override

public void onCancel(Platform arg0, int arg1) {


}

});


}

}

1 0
原创粉丝点击