java - How to implement single logout function for Facebook and Google Authentication -


i implementing facebook , google authentication in android application.

i have completed authentication both of them, logging out application have single button , there 2 different approach logging out either facebook or google.

i need logout application, considering account user logged in application, i.e. facebook or google.

below code logging out facebook:

facebooksdk.sdkinitialize(getapplicationcontext()); loginmanager.getinstance().logout(); 

and, google:

private void signout() {     auth.googlesigninapi.signout(mgoogleapiclient).setresultcallback(             new resultcallback<status>() {                 @override                 public void onresult(status status) {                     // ...                 }             }); } 

how implement these functions according types of accounts user has logged on to.

thanks in advance.

the default answer in object oriented programming: create layer of abstraction.

meaning: start like:

public interface authentification {   public void login();   public void logout(); } 

and create different classes implement interface.

and then, @ runtime, have one single class/method knows which implementation use user - depending if need google/facebook/whatever. method authentification return type.

and other code only deals objects of now: implement interface.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -