新浪登录
private void loginXin(final SHARE_MEDIA platform) { mController.doOauthVerify(MainActivity.this, platform, new UMAuthListener() { @Override public void onStart(SHARE_MEDIA platform) { Toast.makeText(MainActivity.this, "授权开始", Toast.LENGTH_SHORT).show(); } @Override public void onError(SocializeException e, SHARE_MEDIA platform) { Toast.makeText(MainActivity.this, "授权失败", Toast.LENGTH_SHORT).show(); } @Override public void onComplete(Bundle value, SHARE_MEDIA platform) { // 获取uid String uid = value.getString("uid"); if (!TextUtils.isEmpty(uid)) { // uid不为空,获取用户信息 getUserInfoXin(platform); } else { Toast.makeText(MainActivity.this, "授权失败...", Toast.LENGTH_LONG).show(); } } @Override public void onCancel(SHARE_MEDIA platform) { Toast.makeText(MainActivity.this, "授权取消", Toast.LENGTH_SHORT).show(); } }); } private void getUserInfoXin(SHARE_MEDIA platform) { mController.getPlatformInfo(MainActivity.this, platform, new UMDataListener() { @Override public void onStart() { } @Override public void onComplete(int status, Map<String, Object> info) { if (info != null) { Toast.makeText(MainActivity.this, info.toString(), Toast.LENGTH_SHORT).show(); } } }); }
权限
<!-- Push service 运行需要的权限 --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" /> <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /> <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="UMENG_APPKEY"
android:value="xxxxxxxxxxxxxxxxxxxxxx" >
</meta-data>
<meta-data
android:name="UMENG_MESSAGE_SECRET"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" >
</meta-data>
导包,复制资源文件
https://yunpan.cn/cSzZYMwj3MuJ7 访问密码 1d02