I use Facebook SDK 4.1.2 and testing on Android 4.4.2 - I know that I have a Facebook application that has been removed from my mobile phone for testing, which means that the system logs in and authorizes my application through web browsing, provided by the FB SDK.
I get this message in the dialog box every time I clear the memory "You have already resolved {Application Name}"
How to avoid the repeated appearance of this message, which can ruin the user's work?
Knowing this and based on the code below, every time I clear my mobile memory, AccessToken.getCurrentAccessToken () returns null when the application starts, which leads in my code to run two lines below, which, I believe, is responsible for this message.
List<String> PUBLIC_PROFILE_PERMISSION = Arrays.asList("public_profile"); LoginManager.getInstance().logInWithReadPermissions(this, PUBLIC_PROFILE_PERMISSION);
My entry is in the code stream and please submit if it can be improved:
AccessToken mAccessToken; CallbackManager callbackManager; AccessTokenTracker accessTokenTracker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FacebookSdk.sdkInitialize(this); callbackManager = CallbackManager.Factory.create(); updateWithToken(AccessToken.getCurrentAccessToken()); accessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) { updateWithToken(newAccessToken); } }; }
// function updateWithToken (...)
private void updateWithToken(AccessToken currentAccessToken) { if (currentAccessToken != null) { mAccessToken = currentAccessToken; AccessToken.setCurrentAccessToken(currentAccessToken); } else { LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // App code mAccessToken = loginResult.getAccessToken(); AccessToken.setCurrentAccessToken(mAccessToken); } @Override public void onCancel() { // App code } @Override public void onError(FacebookException exception) { Log.d("", ""); } }); List<String> PUBLIC_PROFILE_PERMISSION = Arrays.asList("public_profile"); // public_profile LoginManager.getInstance().logInWithReadPermissions(this, PUBLIC_PROFILE_PERMISSION); //Log in to FB } }
// function onDestroy ()
@Override public void onDestroy() { super.onDestroy(); accessTokenTracker.stopTracking(); }
// function onActivityResult (...)
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); callbackManager.onActivityResult(requestCode, resultCode, data); }