全局的build.gradle中配置
classpath “com.mob.sdk:MobSDK:2018.0319.1724”
全局的APP的build.gradle中配置:
最上边:apply plugin: ‘com.mob.sdk’
下边:MobSDK {
appKey “d580ad56b4b5”
appSecret “7fcae59a62342e7e2759e9e397c82bdd”
ShareSDK {
//平台配置信息
devInfo {
SinaWeibo {
appKey "568898243"
appSecret "38a4f8204cc784f81f9f0daaf31e02e3"
callbackUri "http://www.sharesdk.cn"
shareByAppClient false
}
Wechat {
appId "wx4868b35061f87885"
appSecret "64020361b8ec4c99936c0e3999a9f249"
}
QQ {
appId "100371282"
appKey "aed9b0303e3ed1e27bae87c33761161d"
shareByAppClient true
}
Facebook {
appKey "1412473428822331"
appSecret "a42f4f3f867dc947b9ed6020c2e93558"
callbackUri "https://mob.com"
}
}
}
}
是这样配置:
apply plugin: ‘com.android.application’
apply plugin: ‘com.mob.sdk’
android {
compileSdkVersion 26
defaultConfig {
applicationId “liyuanqi.bwie.com.denglufenxiang”
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName “1.0”
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
}
MobSDK {
appKey “d580ad56b4b5”
appSecret “7fcae59a62342e7e2759e9e397c82bdd”
ShareSDK {
//平台配置信息
devInfo {
SinaWeibo {
appKey "568898243"
appSecret "38a4f8204cc784f81f9f0daaf31e02e3"
callbackUri "http://www.sharesdk.cn"
shareByAppClient false
}
Wechat {
appId "wx4868b35061f87885"
appSecret "64020361b8ec4c99936c0e3999a9f249"
}
QQ {
appId "100371282"
appKey "aed9b0303e3ed1e27bae87c33761161d"
shareByAppClient true
}
Facebook {
appKey "1412473428822331"
appSecret "a42f4f3f867dc947b9ed6020c2e93558"
callbackUri "https://mob.com"
}
}
}
}
dependencies {
implementation fileTree(dir: ‘libs’, include: [’*.jar’])
implementation ‘com.android.support:appcompat-v7:26.1.0’
implementation ‘com.android.support.constraint:constraint-layout:1.1.3’
testImplementation ‘junit:junit:4.12’
androidTestImplementation ‘com.android.support.test?1.0.2’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’
}
分享的代码:
OnekeyShare oks = new OnekeyShare();
//关闭sso授权
oks.disableSSOWhenAuthorize();
// title标题,微信、QQ和QQ空间等平台使用
oks.setTitle(getString(R.string.share));
// titleUrl QQ和QQ空间跳转链接
oks.setTitleUrl("http://sharesdk.cn");
// text是分享文本,所有平台都需要这个字段
oks.setText("我是分享文本");
// imagePath是图片的本地路径,Linked-In以外的平台都支持此参数
oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
// url在微信、微博,Facebook等平台中使用
oks.setUrl("http://sharesdk.cn");
// comment是我对这条分享的评论,仅在人人网使用
oks.setComment("我是测试评论文本");
// 启动分享GUI
oks.show(this);