Java tutorial
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package br.com.oficinatablet; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.FragmentActivity; import com.facebook.AccessToken; import com.facebook.CallbackManager; import com.facebook.FacebookSdk; import br.com.oficinatablet.login.LoginActivity; import br.com.oficinatablet.chats.ChatsSwipeActivity; public class MainActivity extends FragmentActivity { CallbackManager callbackManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // INIT SPLASH SCREEN //////////////////////// setContentView(R.layout.activity_main); FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); AccessToken currentAccessToken = AccessToken.getCurrentAccessToken(); /** * inteno de iniciar a activity de Login */ if (currentAccessToken != null) { showActivity(new Intent(this, ChatsSwipeActivity.class)); } else { showActivity(new Intent(this, LoginActivity.class)); } } private void showActivity(final Intent intent) { new Handler().postDelayed(new Runnable() { @Override public void run() { startActivity(intent); finish(); } }, 1000); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); callbackManager.onActivityResult(requestCode, resultCode, data); } }