title: Cant get Facebook Graph API information through access token on android
body: <p>I am writing a simple app on android to get the information of user who login the app throught Facebook. Here is my codes:</p>
  
  <pre><code>public class example extends Activity {
  
  Facebook facebook = new Facebook("id");
  AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
  
  private static final String TAG ="Debug";
  private SharedPreferences mPrefs;
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_example);
      /*
       * Get existing access_token if any
       */
      mPrefs = getPreferences(MODE_PRIVATE);
      String access_token = mPrefs.getString("access_token", null);
      long expires = mPrefs.getLong("access_expires", 0);
      if(access_token != null) {
          facebook.setAccessToken(access_token);
      }
      if(expires != 0) {
          facebook.setAccessExpires(expires);
      }
  
      /*
       * Only call authorize if the access_token has expired.
       */
      if(!facebook.isSessionValid()) {
  
          facebook.authorize(this, new String[] {"publish_stream","email","user_groups","read_stream","user_about_me","offline_access"}, new DialogListener() {
              @Override
              public void onComplete(Bundle values) {
                  SharedPreferences.Editor editor = mPrefs.edit();
                  editor.putString("access_token", facebook.getAccessToken());
                  editor.putLong("access_expires", facebook.getAccessExpires());
                  editor.commit();
              }
  
              @Override
              public void onFacebookError(FacebookError error) {}
  
              @Override
              public void onError(DialogError e) {}
  
              @Override
              public void onCancel() {}
          });
      }        
      Log.d(TAG, access_token);
      getInformation();
  }
  
  private void getInformation(){
  
      JSONObject json = null;
  
      try
      {
          Log.d("testing", "point1");
          String response = facebook.request("me");
          Log.d("testing", "point2");
          json = Util.parseJson(response);
          String id = json.getString("id");
          Log.d("testing", id);
      }
      catch (MalformedURLException e)
      {
          e.printStackTrace();
      }
      catch (JSONException e)
      {
          e.printStackTrace();
      }
      catch (IOException e)
      {
          e.printStackTrace();
      }
      catch (FacebookError e)
      {
          e.printStackTrace();
      }
  
  }
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      facebook.authorizeCallback(requestCode, resultCode, data);
  }
  
  @Override
  public void onResume() {    
      super.onResume();
      facebook.extendAccessTokenIfNeeded(this, null);
  }
  }
  </code></pre>
  
  <p>I follow here <a href="https://developers.facebook.com/docs/mobile/android/build/#sdk" rel="nofollow">https://developers.facebook.com/docs/mobile/android/build/#sdk</a> and use the same facebook SDK. So as show on the code, in logcat there is only point1 but not point2, which means the facebook.request("me") is not success. The emulator shows the app shut down and say "unfortunately, example has stopped."</p>
  
  <p>So can anyone help me to point out the question? I wondering if the is something wrong in the access token but I dont know about it. Thanks a lot.</p>
  
  <p>LogCat:</p>
  
  <pre><code>11-03 10:13:55.986: D/Debug(893): AAAFi20EvlJEBACwBLIR4buSOaZB1emxACFPZCZAKums6ZCNwZB0wZCvQnI3grshT0YNl8ZC427BSkrNye6akdCZBjvp4KL24Oyx......
  11-03 10:13:55.986: D/testing(893): point1
  11-03 10:13:56.106: D/AndroidRuntime(893): Shutting down VM
  11-03 10:13:56.106: W/dalvikvm(893): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
  11-03 10:13:56.136: E/AndroidRuntime(893): FATAL EXCEPTION: main
  11-03 10:13:56.136: E/AndroidRuntime(893): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crush/com.example.crush.Crush}: android.os.NetworkOnMainThreadException
  11-03 10:13:56.136: E/AndroidRuntime(893):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
  </code></pre>