将facebook与Android应用程序集成会给我带来运行时错误

时间:2014-05-06 07:11:42

标签: android facebook

I am try to integrate facebook with my android app.
My code is like this

package com.example.jiffy;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;
import com.facebook.*;
import com.facebook.model.*;

public class FacebookLoginActivity extends Activity{

    @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.facebooklogin);

        // 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.newMeRequest(session, new Request.GraphUserCallback() {

                // callback after Graph API response with user object
                @Override
                public void onCompleted(GraphUser user, Response response) {
                  if (user != null) {
                    TextView welcome = (TextView) findViewById(R.id.welcome);
                    welcome.setText("Hello " + user.getName() + "!");
                  }
                }
              }).executeAsync();
            }
          }
        });
      }

      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
      }

}

它给我这样的运行时错误

05-06 12:34:59.749: E/AndroidRuntime(1102): FATAL EXCEPTION: main
05-06 12:34:59.749: E/AndroidRuntime(1102): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
05-06 12:34:59.749: E/AndroidRuntime(1102):     at com.facebook.Session.postActiveSessionAction(Session.java:1574)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at com.facebook.Session.setActiveSession(Session.java:971)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at com.facebook.Session.openActiveSession(Session.java:1126)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at com.facebook.Session.openActiveSession(Session.java:1011)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at com.example.jiffy.JiffyFacebookLoginActivity.onCreate(JiffyFacebookLoginActivity.java:18)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.app.Activity.performCreate(Activity.java:5008)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.os.Looper.loop(Looper.java:137)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at android.app.ActivityThread.main(ActivityThread.java:4745)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at java.lang.reflect.Method.invokeNative(Native Method)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at java.lang.reflect.Method.invoke(Method.java:511)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-06 12:34:59.749: E/AndroidRuntime(1102):     at dalvik.system.NativeStart.main(Native Method)

enter code here

0 个答案:

没有答案