友盟的appkey
在清单文件中手写
<meta-data
android:name="UMENG_APPKEY"
android:value="5ad80385b27b0a34200000ce" />
QQ的一个key去腾讯开放平台找
友盟的分享结合开发文档
//分享 UMWeb注意是http开头,一个完整网址
UMImage umImage = new UMImage(DetailActivity.this, "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2769859361,4020179826&fm=27&gp=0.jpg");
String detailUrl = this.detailBean.getData().getDetailUrl();
UMWeb web = new UMWeb(detailUrl);
web.setTitle("我的商品链接分享");//标题
web.setThumb(umImage); //缩略图
web.setDescription("这是一个不错的商品");//描述
new ShareAction(DetailActivity.this)
.withText("hello")
.withMedia(web)
.setDisplayList(SHARE_MEDIA.SINA,SHARE_MEDIA.QQ,SHARE_MEDIA.WEIXIN)
.setCallback(shareListener).open();
break;
}
}
//分享回调
private UMShareListener shareListener = new UMShareListener() {
/**
* @descrption 分享开始的回调
* @param platform 平台类型
*/
@Override
public void onStart(SHARE_MEDIA platform) {
}
/**
* @descrption 分享成功的回调
* @param platform 平台类型
*/
@Override
public void onResult(SHARE_MEDIA platform) {
Toast.makeText(DetailActivity.this,"成功了",Toast.LENGTH_LONG).show();
}
/**
* @descrption 分享失败的回调
* @param platform 平台类型
* @param t 错误原因
*/
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
Toast.makeText(DetailActivity.this,"失败"+t.getMessage(),Toast.LENGTH_LONG).show();
}
/**
* @descrption 分享取消的回调
* @param platform 平台类型
*/
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(DetailActivity.this,"取消了",Toast.LENGTH_LONG).show();
}
};
第三方登录结合开发文档
//动态权限 6.0
if(Build.VERSION.SDK_INT>=23){
String[] mPermissionList = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.CALL_PHONE,Manifest.permission.READ_LOGS,Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.SET_DEBUG_APP,Manifest.permission.SYSTEM_ALERT_WINDOW,Manifest.permission.GET_ACCOUNTS,Manifest.permission.WRITE_APN_SETTINGS};
ActivityCompat.requestPermissions(this,mPermissionList,123);
}
edtel = findViewById(R.id.edtel);
edpass = findViewById(R.id.edpass);
loRePresenter = new LoRePresenter(this);
}
//权限回调
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
}
//QQ 新浪
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
}
//第三方qq登陆
public void qqLogin(View view) {
UMShareAPI.get(LoginActivity.this).getPlatformInfo(LoginActivity.this, SHARE_MEDIA.QQ, authListener);
Intent intent = new Intent(LoginActivity.this,ShoppListActivity.class);
startActivity(intent);
//finish();
}
//第三方qq登陆监听
UMAuthListener authListener = new UMAuthListener() {
/**
* @desc 授权开始的回调
* @param platform 平台名称
*/
@Override
public void onStart(SHARE_MEDIA platform) {
}
/**
* @desc 授权成功的回调
* @param platform 平台名称
* @param action 行为序号,开发者用不上
* @param data 用户资料返回
*/
@Override
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
Toast.makeText(LoginActivity.this, "成功了", Toast.LENGTH_LONG).show();
/* //遍历Map集合
Set<String> keySet = data.keySet();
for (String key: keySet) {
String value = data.get(key);
info.append("信息" + platform + "---" +action + "----" +key +"---"+value +"\r\n");}*/
}
/**
* @desc 授权失败的回调
* @param platform 平台名称
* @param action 行为序号,开发者用不上
* @param t 错误原因
*/
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
Toast.makeText(LoginActivity.this, "失败:" + t.getMessage(), Toast.LENGTH_LONG).show();
}
/**
* @desc 授权取消的回调
* @param platform 平台名称
* @param action 行为序号,开发者用不上
*/
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
Toast.makeText(LoginActivity.this, "取消了", Toast.LENGTH_LONG).show();
}
};