Meine Android App starten mit einer Facebook-Login-Seite und wenn der Benutzer Jet angemeldet ist, überspringen Sie die Homepage.Login-Seite für eine Sekunde angezeigt
Das Problem ist, dass wenn der Benutzer Jet protokolliert wird die Startseite für eine Sekunde angezeigt wird.
Hier ist mein Starter-Code:
public class MainActivity extends AppCompatActivity {
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
private AccessTokenTracker mAccessTokenTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
final Context context=this;
if (AccessToken.getCurrentAccessToken() != null) {
mAccessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
mAccessTokenTracker.stopTracking();
if(currentAccessToken == null) {
Log.i("LOGIN","ALL PERMISSION DELETED, SKIP TO THE LOGIN");
}
else {
//CHECK PERMISSION ONE BY ONE
String current_permission =currentAccessToken.getPermissions().toString();
if (current_permission.contains("user_photos") && current_permission.contains("user_post") && current_permission.contains("public_profile")) {
Toast.makeText(getApplicationContext(), "YOU ARE LOGGED IN", Toast.LENGTH_LONG).show();
Intent intent = new Intent(context, HomeActivity.class);
context.startActivity(intent); //USER IS LOGGED IN AND HAVE ALL PERMISSION SO GO TO THE HOME PAGE
}
}
}
};
AccessToken.refreshCurrentAccessTokenAsync();
}
else {
Log.i("LOGIN","NEED TO LOG IN");
}
setContentView(R.layout.activity_main);
......
//GO TO THE LOGIN PAGE
Wie kann ich das vermeiden und was ist die beste Praxis?