要运用第三方登陆,需要按照官网进行封装,这一步在这里就省略了
这里只是做一个获取头像的功能
配置文件也就是关联一下 以及权限
android:name="com.andy.share.App"
public class MainActivity extends AppCompatActivity{ private ImageView image; private QQOauthUtils mQQOauthUtils; private TextView name1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); image= (ImageView) findViewById(R.id.image); name1 = (TextView) findViewById(R.id.name); mQQOauthUtils=new QQOauthUtils(this, new QQOauthUtils.IUserPhoto() { @Override public void userPhoto(String userPhoto,String name) { Glide.with(MainActivity.this).load(userPhoto).into(image); name1.setText(name); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.e("0000000000000000000000000",data.toString()); mQQOauthUtils.onActivityResult(requestCode,resultCode,data); } public void but(View v) { mQQOauthUtils.qqLogin(); } }