compile files('libs/SocialSDK_QQ_Simplify.jar')
compile files('libs/umeng_shareboard_widget.jar')
compile files('libs/umeng_social_api.jar')
compile files('libs/umeng_social_net.jar')
compile files('libs/umeng_social_shareboard.jar')
compile files('libs/umeng_social_tool.jar')
compile 'com.jakewharton:butterknife:7.0.1'
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<activity
android:name="com.umeng.qq.tencent.AuthActivity"
android:launchMode="singleTask"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tencent100424468" />
</intent-filter>
</activity>
<activity
android:name="com.umeng.qq.tencent.AssistActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<meta-data
android:name="UMENG_APPKEY"
android:value="5a1f9e26a40fa30def00037e" >
</meta-data>
<Button
android:id="@+id/btn_sharewithboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="带面板的内容分享" />
<Button
android:id="@+id/btn_sharewithoutboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="不带面板的内容分享" />
<Button
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="友盟第三方登录" />
xml,照片,java
{
PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad", "http://sns.whalecloud.com");
}
@Override
public void onCreate() {
super.onCreate();
UMShareAPI.get(this);
Config.DEBUG = true;
}
private Button btn_sharewithboard;
private Button btn_sharewithoutboard;
private Button btn_login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
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);
}
}
private void initView() {
btn_sharewithboard = (Button) findViewById(R.id.btn_sharewithboard);
btn_sharewithoutboard = (Button) findViewById(R.id.btn_sharewithoutboard);
btn_login = (Button) findViewById(R.id.btn_login);
btn_sharewithboard.setOnClickListener(this);
btn_sharewithoutboard.setOnClickListener(this);
btn_login.setOnClickListener(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_sharewithboard:
//分享的内容图片
UMImage image = new UMImage(MainActivity.this, R.mipmap.share);//资源文件
//调用内容分享方法
new ShareAction(MainActivity.this)
.withText("hello")
.withMedia(image)
.setDisplayList(SHARE_MEDIA.SINA, SHARE_MEDIA.QQ, SHARE_MEDIA.WEIXIN)
.setCallback(shareListener)
.open();
break;
case R.id.btn_sharewithoutboard:
UMImage share_image = new UMImage(MainActivity.this, R.mipmap.ic_launcher);//资源文件
new ShareAction(MainActivity.this)
.setPlatform(SHARE_MEDIA.QQ)//传入平台
.withText("hello")//分享内容
.withMedia(share_image)
.setCallback(shareListener)//回调监听器
.share();
break;
case R.id.btn_login:
//Toast.makeText(MainActivity.this, "aaa", Toast.LENGTH_SHORT).show();
UMShareAPI umShareAPI = UMShareAPI.get(this);
umShareAPI.getPlatformInfo(MainActivity.this, SHARE_MEDIA.QQ, new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA share_media) {
}
@Override
public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {
//tv.setText(map.get("name"));
//Picasso.with(MainActivity.this).load(map.get("iconurl")).into(img);
}
@Override
public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {
}
@Override
public void onCancel(SHARE_MEDIA share_media, int i) {
}
});
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(MainActivity.this, "成功了", Toast.LENGTH_LONG).show();
}
/**
* @descrption 分享失败的回调
* @param platform 平台类型
* @param t 错误原因
*/
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
Toast.makeText(MainActivity.this, "失败" + t.getMessage(), Toast.LENGTH_LONG).show();
}
/**
* @descrption 分享取消的回调
* @param platform 平台类型
*/
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(MainActivity.this, "取消了", Toast.LENGTH_LONG).show();
}
};
//登录内容的监听
private UMAuthListener umAuthListener = new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA platform) {
//授权开始的回调
}
@Override
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
Toast.makeText(getApplicationContext(), "Authorize succeed", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
Toast.makeText(getApplicationContext(), "Authorize fail", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
Toast.makeText(getApplicationContext(), "Authorize cancel", Toast.LENGTH_SHORT).show();
}
};
compile files('libs/umeng_shareboard_widget.jar')
compile files('libs/umeng_social_api.jar')
compile files('libs/umeng_social_net.jar')
compile files('libs/umeng_social_shareboard.jar')
compile files('libs/umeng_social_tool.jar')
compile 'com.jakewharton:butterknife:7.0.1'
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<activity
android:name="com.umeng.qq.tencent.AuthActivity"
android:launchMode="singleTask"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tencent100424468" />
</intent-filter>
</activity>
<activity
android:name="com.umeng.qq.tencent.AssistActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<meta-data
android:name="UMENG_APPKEY"
android:value="5a1f9e26a40fa30def00037e" >
</meta-data>
<Button
android:id="@+id/btn_sharewithboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="带面板的内容分享" />
<Button
android:id="@+id/btn_sharewithoutboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="不带面板的内容分享" />
<Button
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="友盟第三方登录" />
xml,照片,java
{
PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad", "http://sns.whalecloud.com");
}
@Override
public void onCreate() {
super.onCreate();
UMShareAPI.get(this);
Config.DEBUG = true;
}
private Button btn_sharewithboard;
private Button btn_sharewithoutboard;
private Button btn_login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
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);
}
}
private void initView() {
btn_sharewithboard = (Button) findViewById(R.id.btn_sharewithboard);
btn_sharewithoutboard = (Button) findViewById(R.id.btn_sharewithoutboard);
btn_login = (Button) findViewById(R.id.btn_login);
btn_sharewithboard.setOnClickListener(this);
btn_sharewithoutboard.setOnClickListener(this);
btn_login.setOnClickListener(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_sharewithboard:
//分享的内容图片
UMImage image = new UMImage(MainActivity.this, R.mipmap.share);//资源文件
//调用内容分享方法
new ShareAction(MainActivity.this)
.withText("hello")
.withMedia(image)
.setDisplayList(SHARE_MEDIA.SINA, SHARE_MEDIA.QQ, SHARE_MEDIA.WEIXIN)
.setCallback(shareListener)
.open();
break;
case R.id.btn_sharewithoutboard:
UMImage share_image = new UMImage(MainActivity.this, R.mipmap.ic_launcher);//资源文件
new ShareAction(MainActivity.this)
.setPlatform(SHARE_MEDIA.QQ)//传入平台
.withText("hello")//分享内容
.withMedia(share_image)
.setCallback(shareListener)//回调监听器
.share();
break;
case R.id.btn_login:
//Toast.makeText(MainActivity.this, "aaa", Toast.LENGTH_SHORT).show();
UMShareAPI umShareAPI = UMShareAPI.get(this);
umShareAPI.getPlatformInfo(MainActivity.this, SHARE_MEDIA.QQ, new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA share_media) {
}
@Override
public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {
//tv.setText(map.get("name"));
//Picasso.with(MainActivity.this).load(map.get("iconurl")).into(img);
}
@Override
public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {
}
@Override
public void onCancel(SHARE_MEDIA share_media, int i) {
}
});
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(MainActivity.this, "成功了", Toast.LENGTH_LONG).show();
}
/**
* @descrption 分享失败的回调
* @param platform 平台类型
* @param t 错误原因
*/
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
Toast.makeText(MainActivity.this, "失败" + t.getMessage(), Toast.LENGTH_LONG).show();
}
/**
* @descrption 分享取消的回调
* @param platform 平台类型
*/
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(MainActivity.this, "取消了", Toast.LENGTH_LONG).show();
}
};
//登录内容的监听
private UMAuthListener umAuthListener = new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA platform) {
//授权开始的回调
}
@Override
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
Toast.makeText(getApplicationContext(), "Authorize succeed", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
Toast.makeText(getApplicationContext(), "Authorize fail", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
Toast.makeText(getApplicationContext(), "Authorize cancel", Toast.LENGTH_SHORT).show();
}
};