Android facebook login reappears on activity finish

时间:2017-04-06 17:14:22

标签: android facebook

I am using Facebook SDK 4+ to add login to my android app. My code checks if there is already an existing access token and redirects the user to the MainActivity if there is one. So when I hit back in the MainActivity, the app closes down. That is fine but after closing down, again the facebook webview for login is loaded. Is there anything that I specifically need to add to the onBackPressed()? Couldn't fix this error for many hours now. Any help would be appreciated. Have any of you had encountered the same issue before. and how do I solve it.


After the app closes down, the webview loads on the home screen and I don't understand why.


1 个答案:

答案 0 :(得分:0)

Add finish(); in your LoginActivity after redirecting the user to the MainActivity (once you've checked if there is an existing access token).

In addition, add

android:launchMode="singleTask" android:noHistory="true"

to the LoginActivity-entry in your AndroidManifest.xml file