um
lisbs目录包
基础权限
<uses-permission Android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WiFi_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
QQ Activity
<activity
android:name="com.tencent.tauth.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>
<meta-data
android:name="UMENG_APPKEY"
android:value="5c344d1af1f5566ed5000e05" />
<meta-data
android:name="UMENG_CHANNEL"
android:value="Umeng" />
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:theme="@android:style/Theme.Translucent.NotitleBar"
android:configChanges="orientation|keyboardhidden|screenSize"/>
App 初始化 appkey保持一致
UMconfigure.init(this,"5c344d1af1f5566ed5000e05","umeng",UMConfigure.DEVICE_TYPE_PHONE,"null");
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
PlatformConfig.setWeixin("wxdc1e388c3822c80b", "3baf1193c85774b3fd9d18447d76cab0");
//豆瓣RENREN平台目前只能在服务器端配置
PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad","http://sns.whalecloud.com");
PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");
PlatformConfig.setqqzone("100424468", "c7394704798a158208a74ab60104f0ba");
PlatformConfig.setTwitter("3aiN7fuF685MuZ7jtXkQxalyi", "MK6FEYG63eWcpdfgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");
PlatformConfig.setAlipay("2015111700822536");
PlatformConfig.setLaiwang("laiwangd497e70d4", "d497e70d4c3e4efeab1381476bac4c5e");
PlatformConfig.setPinterest("1439206");
PlatformConfig.setKakao("e4f60e065048eb031e235c806b31c70f");
PlatformConfig.setDing("dingoalmlnohc0wggfedpk");
PlatformConfig.setVKontakte("5764965","5My6SNliAaLxEm3Lyd9J");
PlatformConfig.setDropbox("oz8v5apet3arcdy","h7p2pjbzkkxt02a");
主页面代码
public class MainActivity extends AppCompatActivity {
@BindView(R.id.btn_share_withoutboard)
Button btnShareWithoutboard;
@BindView(R.id.btn_share_withboard)
Button btnShareWithboard;
@BindView(R.id.btn_login)
Button btnLogin;
@BindView(R.id.iv_icon)
ImageView ivIcon;
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();
}
};
@Override
protected void onCreate(Bundle savedinstanceState) {
super.onCreate(savedInstanceState);
setcontentView(R.layout.activity_main);
ButterKnife.bind(this);
//Android6.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);
}
}
@Override
public void onRequestPermissionsResult(int requestcode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
UMShareAPI.get(this).onActivityResult(requestCode,requestCode,data);
}
@OnClick({R.id.btn_share_withoutboard, R.id.btn_share_withboard, R.id.btn_login})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.btn_share_withoutboard:
UMImage image = new UMImage(MainActivity.this,R.drawable.littlegirl );//网络图片
new ShareAction(MainActivity.this)
.setPlatform(SHARE_MEDIA.QQ)//传入平台
.withText("hello")//分享内容
.withMedia(image)
.setCallback(shareListener)//回调监听器
.share();
break;
case R.id.btn_share_withboard:
UMImage images = new UMImage(MainActivity.this,R.drawable.littlegirl );//网络图片
new ShareAction(MainActivity.this)
.withText("hello")
.withMedia(images)
.setdisplayList(SHARE_MEDIA.SINA,SHARE_MEDIA.QQ,SHARE_MEDIA.WEIXIN)
.setCallback(shareListener).open();
break;
case R.id.btn_login:
//获取友盟封装的分享对象
UMShareAPI umShareAPI = UMShareAPI.get(this);
//切记平台切换
umShareAPI.getPlatformInfo(MainActivity.this, SHARE_MEDIA.QQ, authListener);
break;
}
}
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(MainActivity.this, "成功了", Toast.LENGTH_LONG).show();
}
/**
* @desc 授权失败的回调
* @param platform 平台名称
* @param action 行为序号,开发者用不上
* @param t 错误原因
*/
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
Toast.makeText(MainActivity.this, "失败:" + t.getMessage(),Toast.LENGTH_LONG).show();
}
/**
* @desc 授权取消的回调
* @param platform 平台名称
* @param action 行为序号,开发者用不上
*/
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
Toast.makeText(MainActivity.this, "取消了", Toast.LENGTH_LONG).show();
}
};
}
相关阅读
EM算法原理:不作过多引言专注推导,先打个比方,一个袋子有10个球,但不清楚里面有些什么颜色的球,但是又不能打开袋子看,所以我们尝试通过
UML类图的作用是描述程序中类的信息及各个类之间的关系。所有的面向对象(Object Oriented)语言都离不开类的概念,理解了程序中类的设
天猫魔盒作为一款大众喜爱的电视盒子产品,因其讨巧的外观和出众的性能让诸多消费者满意,下面就来教教大家天猫魔盒如何通过当贝市场
JavaScript中document的write()的一个使用细节
最近在做一个微信小程序,之中用到了html,CSS,JS这些方面的知识,我一直觉得前端很好玩,就开始学习JS方面的知识。 因为是初学,直接很全
前言 最近因为工作需要 用selenium做了一个QQ邮箱的爬虫(登录时部分帐号要滑动解锁),先简单记录一下。这个问题先可以分为两个部