android facebook login connect error
<p>i write an app that use the facebook login, i did everything that was wrote on facebook android sdk getting started, however i get an error:</p>

<p>here is my mainActivity:</p>

<pre><code>import java.io.ByteArrayOutputStream;
import com.facebook.*;
import com.facebook.model.*;
import java.io.File;
import java.util.Arrays;

import android.app.ActionBar;
import android.app.Activity;

import com.parse.GetCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;
import com.parse.PushService;
import com.parse.SaveCallback;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

    private Button logInButton;
    private TextView registerScreen;
    private TextView userText;
    private TextView passwordText;
    private SharedPreferences loginPreferences;
    private SharedPreferences.Editor loginPrefsEditor;
    private Boolean saveLogin;
    private CheckBox saveLoginCheckBox;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.main_menu_2:
            //Goto the DetailActivity
            Intent intent = new Intent();
            intent.setClass(this, ProfileActivity.class);
            startActivity(intent);
            break;
        }
        return true;
    }



    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);


        Parse.initialize(this, "QUp32HaGmSmHHbXkgsBrgunfG5jUAmfxRcWQtAZx", "BTF06lCl8RBP2lFyv8GZLW844D6wDUg0Qw2dUfx3");

        //ParseFacebookUtils.initialize("376023535838313");

         registerScreen = (TextView) findViewById(R.id.link_to_register);
         logInButton = (Button) findViewById(R.id.btnLogin);

         userText =  (TextView) findViewById(R.id.UserNameText);

         passwordText=  (TextView) findViewById(R.id.PasswordText);

         saveLoginCheckBox = (CheckBox)findViewById(R.id.saveLoginCheckBox);
         loginPreferences = getSharedPreferences("loginPrefs", MODE_PRIVATE);
         loginPrefsEditor = loginPreferences.edit();

          // start Facebook Login-----------------------------------------------
        Session.openActiveSession(this, true, new Session.StatusCallback() {

          // callback when session changes state
          @Override
          public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened()) {

              // make request to the /me API
              Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                // callback after Graph API response with user object
                @Override
                public void onCompleted(GraphUser user, Response response) {
                  if (user != null) {
                     Intent i = new Intent(getApplicationContext(), MainActivity.class);        

                        Bundle firstName = new Bundle();
                        firstName.putString("userFirstName", user.getFirstName()); //Your id
                        Bundle lastName = new Bundle();
                        lastName.putString("userLastName", user.getLastName());
                        Bundle userId = new Bundle();
                        userId.putString("userId", user.getId());
                        i.putExtras(firstName); //Put your id to your next Intent
                        i.putExtras(lastName); 
                        i.putExtras(userId); 
                        GraphLocation gl= user.getLocation();
                        String country= gl.getCountry();
                        String city =gl.getCity();
                        String street=gl.getStreet();
                        Bundle Country = new Bundle();
                        Country.putString("Country", country);
                        Bundle City = new Bundle();
                        City.putString("City", city);
                        Bundle Street = new Bundle();
                        Street.putString("Street", street);
                        i.putExtras(Country);
                        i.putExtras(City);
                        i.putExtras(Street);
                        startActivity(i);
                  }
                }
              });
            }
          }
        });

        // Finish facebok login --------------------------------------------
        View titleView = getWindow().findViewById(android.R.id.title);
        if (titleView != null) {
            ViewParent parent = titleView.getParent();
            if (parent != null &amp;&amp; (parent instanceof View)) {
             View parentView = (View)parent;
             parentView.setVisibility(View.GONE);
            }
        }


         saveLogin = loginPreferences.getBoolean("saveLogin", false);
            if (saveLogin == true) {
                userText.setText(loginPreferences.getString("username", ""));
                passwordText.setText(loginPreferences.getString("password", ""));
                saveLoginCheckBox.setChecked(true);
            }

         //listen to log in button


         logInButton.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View v) {
                    if(userText.getText().toString().equals("")) {
                        Toast.makeText(getApplicationContext(), "Invalid User Name", Toast.LENGTH_SHORT).show();
                    }
                    else if(passwordText.getText().toString().equals("")) {
                        Toast.makeText(getApplicationContext(), "Invalid Password", Toast.LENGTH_SHORT).show();
                    }
                    else {
                        try {
                            String username = userText.getText().toString();
                            String password = passwordText.getText().toString();
                            if (saveLoginCheckBox.isChecked()) {
                                loginPrefsEditor.putBoolean("saveLogin", true);
                                loginPrefsEditor.putString("username", username);
                                loginPrefsEditor.putString("password", password);
                                loginPrefsEditor.commit();
                            } else {
                                loginPrefsEditor.clear();
                                loginPrefsEditor.commit();
                            }

                            ParseUser.logIn(userText.getText().toString(), passwordText.getText().toString());

                            Intent i = new Intent(getApplicationContext(), ProfileActivity.class);                          
                            Bundle b = new Bundle();
                            b.putString("userName", userText.getText().toString()); //Your id
                            i.putExtras(b); //Put your id to your next Intent
                            startActivity(i);


                        } catch (ParseException e) {
                            // TODO Auto-generated catch block
                            Toast.makeText(getApplicationContext(), "User Does not Exist!", Toast.LENGTH_SHORT).show();

                        }
                    }
                }
            });
        // Listening to register new account link
        registerScreen.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // Switching to Register screen
                Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
                startActivity(i);
            }
        });
    }
}
</code></pre>

<p>and here is the logcat:</p>

<pre><code>03-03 13:13:32.393: E/AndroidRuntime(2060): FATAL EXCEPTION: main
03-03 13:13:32.393: E/AndroidRuntime(2060): java.lang.NullPointerException
03-03 13:13:32.393: E/AndroidRuntime(2060):     at com.example..MainActivity$1$1.onCompleted(MainActivity.java:121)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at com.facebook.Request$1.onCompleted(Request.java:264)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at com.facebook.Request$4.run(Request.java:1240)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at android.os.Handler.handleCallback(Handler.java:725)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at android.os.Looper.loop(Looper.java:137)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at android.app.ActivityThread.main(ActivityThread.java:5041)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at java.lang.reflect.Method.invokeNative(Native Method)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at java.lang.reflect.Method.invoke(Method.java:511)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-03 13:13:32.393: E/AndroidRuntime(2060):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>i get a message: " your app must stopped.." when i start the mainActivity..
thanks alot</p>
