Android third-party login detailed 2

Source: Internet
Author: User

Then Android third-party login detailed 1 speak

1. Find the Friend League Documentation Center

2. Find

3. The

Umsocialservice Mcontroller = Umservicefactory.getumsocialservice ("Com.umeng.login");

This sentence is put into the corresponding activity to make a global can

4QQ Login

Parameter 1 is the current activity, parameter 2 for the developer in the QQ Internet application app ID, Parameter 3 for the developer in the QQ Internet Application app KEY.    Umqqssohandler Qqssohandler = new Umqqssohandler (This, "100424468",                    "C7394704798a158208a74ab60104f0ba");    QQSSOHANDLER.ADDTOSOCIALSDK ();

5 Put the above code into activity OnCreate (Bundle savedinstancestate) {} Guide Pack

6 found Androidmanifest.xml

7 put the following code inside add a permission <uses-permission android:name= "Android.permission.GET_TASKS"/>

<!--############ QQ space and QQ SSO authorized activity registration ############--
<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= "Tencent your QQ interconnection AppID"/>
</intent-filter>
</activity>
<activity android:name= "Com.tencent.connect.common.AssistActivity"
Android:theme= "@android: Style/theme.translucent.notitlebar"
android:screenorientation= "Portrait" >
</activity>

8. Play in the corresponding button monitor

/**
* QQ Login
* */
private void Qqdenglu () {
Listening
Qq.setonclicklistener (New Onclicklistener () {

@Override
public void OnClick (View v) {
TODO auto-generated Method Stub


Mcontroller.dooauthverify (Mcontext, Share_media. QQ, New Umauthlistener () {
@Override
public void OnStart (Share_media platform) {
Toast.maketext (Mcontext, "Licensing start", Toast.length_short). Show ();
}
@Override
public void OnError (Socializeexception e, Share_media platform) {
Toast.maketext (Mcontext, "Authorization Error", Toast.length_short). Show ();
}
@Override
public void OnComplete (Bundle value, Share_media platform) {
Toast.maketext (Mcontext, "authorized completion", Toast.length_short). Show ();
Get relevant licensing information
Mcontroller.getplatforminfo (Homepage.this, Share_media. QQ, New Umdatalistener () {
@Override
public void OnStart () {
Toast.maketext (Homepage.this, "Get Platform data start ...", Toast.length_short). Show ();
}
@Override
public void OnComplete (int status, map<string, object> info) {
if (status = = && info! = null) {
StringBuilder sb = new StringBuilder ();
set<string> keys = Info.keyset ();

/* for (String Key:keys) {
Sb.append (key+ "=" +info.get (key). ToString () + "\ r \ n"); */

// }

Change to QQ head
String u = (string) info.get ("Profile_image_url");
Assigning Values to ImageView
Imageloader.getinstance (). DisplayImage (U, Tiouxiang);
QQ User name Screen_name
String name = (string) info.get ("Screen_name");
TextView Assignment Value
Text_name.settext ("+name");

LOG.D ("TestData", sb.tostring ());

}else{
LOG.D ("TestData", "Error occurred:" +status);
}
}
});
}
@Override
public void OnCancel (Share_media platform) {
Toast.maketext (Mcontext, "authorization cancellation", Toast.length_short). Show ();
}
} );
}
});
}

9. Complete

10. Weibo login and then hit a micro-blog monitor inside.

Mcontroller.dooauthverify (activity, Share_media. Sina,new Umauthlistener () {
@Override
public void OnError (Socializeexception e, Share_media platform) {
}
@Override
public void OnComplete (Bundle value, Share_media platform) {
if (value! = NULL &&!) Textutils.isempty (value.getstring ("UID"))) {
Toast.maketext (activity, "authorization succeeded.", Toast.length_short). Show ();
} else {
Toast.maketext (activity, "Authorization failed", Toast.length_short). Show ();
}
Mcontroller.getplatforminfo (activity, Share_media. SINA, New Umdatalistener () {
@Override
public void OnStart () {
Toast.maketext (activity, "Get platform data start ...", Toast.length_short). Show ();
}
@Override
public void OnComplete (int status, map<string, object> info) {
if (status = = && info! = null) {
StringBuilder sb = new StringBuilder ();
set<string> keys = Info.keyset ();
for (String Key:keys) {
Sb.append (key+ "=" +info.get (key). ToString () + "\ r \ n");
// }
Profile_image_url
Change to Weibo Avatar
String u = (string) info.get ("Profile_image_url");
Imageloader.getinstance (). DisplayImage (U, Tiouxiang);
Weibo user name Screen_name
String name = (string) info.get ("Screen_name");
Text_name.settext ("+name");
System.out.println (sb.tostring () + "VVVVVVVVVVVVV");
LOG.D ("TestData", sb.tostring ());
}else{
LOG.D ("TestData", "Error occurred:" +status);
}
}
});
}
@Override
public void OnCancel (Share_media platform) {}
@Override
public void OnStart (Share_media platform) {}
});

Android third-party login detailed 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.