title: Android Error: Unable to resume activity..?
body: <p>I'm new to android and trying to add Facebook login and catch the event after clicking the Logout button(using AccessTokenTracker) in android using facebook sdk using Android studio but i'm getting this error<br/><br/>
  here is the logcat,<br/></p>
  
  <pre><code>// (please horizontal scroll for logcat)
  01-12 00:47:15.306 12572-12572/com.example.arpit.facebooklogindemo E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                   java.lang.RuntimeException: Unable to resume activity {com.example.arpit.facebooklogindemo/com.example.arpit.facebooklogindemo.MainActivity}: java.lang.NullPointerException
   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2790)
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2819)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2266)
   at android.app.ActivityThread.access$600(ActivityThread.java:141)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:5103)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:525)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
   at dalvik.system.NativeStart.main(Native Method)
                                                                                    Caused by: java.lang.NullPointerException
   at com.example.arpit.facebooklogindemo.MainActivity.onResume(MainActivity.java:83)
   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
   at android.app.Activity.performResume(Activity.java:5211)
   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2780)
  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2819) 
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2266) 
  at android.app.ActivityThread.access$600(ActivityThread.java:141) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
  at android.os.Handler.dispatchMessage(Handler.java:99) 
  at android.os.Looper.loop(Looper.java:137) 
  at android.app.ActivityThread.main(ActivityThread.java:5103) 
  at java.lang.reflect.Method.invokeNative(Native Method) 
  at java.lang.reflect.Method.invoke(Method.java:525) 
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Here is AndroidManifest.xml,<br/></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.arpit.facebooklogindemo"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
  
           //from http://developers.facebook.com
          &lt;meta-data android:name="com.facebook.sdk.ApplicationId"
              android:value="@string/app_id"/&gt;
  
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          //from http://developers.facebook.com
          &lt;activity android:name="com.facebook.FacebookActivity"
              android:configChanges=
                  "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
              android:theme="@android:style/Theme.Translucent.NoTitleBar"
              android:label="@string/app_name" /&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Here is activity_main.xml,<br/></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.arpit.facebooklogindemo.MainActivity"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hello World!"
          android:id="@+id/textView2" /&gt;
  
       //from http://developers.facebook.com
      &lt;com.facebook.login.widget.LoginButton
          android:id="@+id/login_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_centerVertical="true"
          android:layout_centerHorizontal="true" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:text="Large Text"
          android:id="@+id/textView"
          android:layout_above="@+id/login_button"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="90dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is MainActivity.java,<br/></p>
  
  <pre><code>package com.example.arpit.facebooklogindemo;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.facebook.AccessToken;
  import com.facebook.AccessTokenTracker;
  import com.facebook.CallbackManager;
  import com.facebook.FacebookCallback;
  import com.facebook.FacebookException;
  import com.facebook.FacebookSdk;
  import com.facebook.Profile;
  import com.facebook.login.LoginResult;
  import com.facebook.login.widget.LoginButton;
  
  public class MainActivity extends AppCompatActivity {
  
      CallbackManager callbackManager;
      LoginButton loginButton;
      TextView textView;
      AccessTokenTracker accessTokenTracker;
  
      private FacebookCallback&lt;LoginResult&gt; mFacebookCallback = new FacebookCallback&lt;LoginResult&gt;() {
          @Override
          public void onSuccess(LoginResult loginResult) {
              Profile profile = Profile.getCurrentProfile();
              if(profile != null){
                  fillTextView(profile);
              }
          }
  
          @Override
          public void onCancel() {
  
          }
  
          @Override
          public void onError(FacebookException error) {
              Log.d("find", String.valueOf(error));
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          FacebookSdk.sdkInitialize(getApplicationContext());
          setContentView(R.layout.activity_main);
          textView = (TextView)findViewById(R.id.textView);
  
          callbackManager = CallbackManager.Factory.create();
  
          accessTokenTracker = new AccessTokenTracker() {
              @Override
              protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
                  if(currentAccessToken == null){
                      textView.setText("Logged out");
                  }
              }
          };
          accessTokenTracker.startTracking();
  
          loginButton = (LoginButton)findViewById(R.id.login_button);
  
          loginButton.registerCallback(callbackManager, mFacebookCallback);
  
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          callbackManager.onActivityResult(requestCode, resultCode, data);
      }
  
      @Override
      protected void onResume(){
          super.onResume();
          Profile profile = Profile.getCurrentProfile();
          textView.setText(profile.getName());
      }
  
      @Override
      protected void onDestroy(){
          super.onDestroy();
          accessTokenTracker.stopTracking();
      }
  
      private void fillTextView(Profile profile){
          textView.setText(profile.getName());
      }
  }
  </code></pre>