add option to login using twitter, facebook and google using socialauth on android app -
add option to login using twitter, facebook and google using socialauth on android app -
i building app connects website fetch data. login screen provided gives alternative of logging in using site username , password or using social apps facebook, twitter , google. buttons provided. have downloaded socialauth library utilize app. followed https://code.google.com/p/socialauth-android/ instructions on how utilize library. documentation rather sketchy. help on how utilize library appreciated. in advance. edit: want provide login facility of facebook, google , twitter log app feature provided on many web sites , apps. again.
i putting here code..hope help you.. note: need set oath_consumer.properties in assets folder add together socialauth library in project.
public class clientlogin extends activity { textview facebooklogin,twitterlogin,linkedinlogin; socialauthadapter adapter; button logout; context context; profile profilemap; string email,password; string provider_name; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.client_login); context=this; facebooklogin=(textview) findviewbyid(r.id.textview_loginfacebook); twitterlogin=(textview) findviewbyid(r.id.textview_logintwitter); linkedinlogin=(textview) findviewbyid(r.id.textview_loginlinkedin); logout=(button) findviewbyid(r.id.button_loginlogout); adapter = new socialauthadapter(new responselistener()); facebooklogin.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub provider_name="facebook"; adapter.authorize(context, provider.facebook); } }); twitterlogin.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { provider_name="twitter"; adapter.authorize(context, provider.twitter); } }); linkedinlogin.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { provider_name="linkedin"; adapter.authorize(context, provider.linkedin); } }); logout.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stubadapter. adapter.signout(context, provider.facebook.tostring()) ; adapter.signout(context, provider.linkedin.tostring()) ; adapter.signout(context, provider.twitter.tostring()) ; toast.maketext(context,"succesfully logged out",1000).show(); } }); } private final class responselistener implements dialoglistener { public void oncomplete(bundle values) { // log.d("sharebutton" , "authentication successful"); toast.maketext(context,"succesfully logged in",1000).show(); //code email id of user... profilemap = adapter.getuserprofile(); if (provider_name.equalsignorecase("facebook")) { //to email_id of user.. email=profilemap.getemail(); } else if( provider_name.equalsignorecase("twitter")) { //to email of user email=profilemap.getemail(); } else if (provider_name.equalsignorecase("linkedin")) { email=profilemap.getemail(); } } } }
android facebook twitter socialauth
Comments
Post a Comment