「Parse」を使用してAndroidのFacebook統合用の簡単なプログラムを作成しましたが、次のコードを使用しましたが、私のコードとlogcatの例外を以下に示します:
main.java
パッケージcom.example.facbk;
import com.facebook.android.AsyncFacebookRunner;
import com.facebook.android.Facebook;
import com.parse.LogInCallback;
import com.parse.Parse;
import com.parse.ParseFacebookUtils;
import com.parse.ParseUser;
import android.net.ParseException;
import android.os.Bundle;
import android.provider.SyncStateContract.Constants;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
private static String APP_ID =" 454641867918042";
private Facebook facebook;
private AsyncFacebookRunner mAsyncRunner;
String FILENAME = "AndroidSSO_data";
Button login;
private SharedPreferences mPrefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Parse.initialize(this, "454641867918042", "aWEd6rRA18hQJNVueCzeVUqqPkkDKAxp8moP3IP");// Try by Adding this method before ParseFacebookUtils.initialize()
ParseFacebookUtils.initialize("454641867918042");
setContentView(R.layout.activity_main);
System.out.println("hello login");
ParseFacebookUtils.logIn(this, new LogInCallback() {
@Override
public void done(ParseUser user, com.parse.ParseException arg1) {
// TODO Auto-generated method stub
if (user == null) {
Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew()) {
Log.d("MyApp", "User signed up and logged in through Facebook!");
} else {
Log.d("MyApp", "User logged in through Facebook!");
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ParseFacebookUtils.finishAuthentication(requestCode, resultCode, data);
}
}
ログキャット
07-11 11:04:34.751: I/dalvikvm(8972): threadid=3: reacting to signal 3
07-11 11:04:34.951: I/dalvikvm(8972): Wrote stack traces to '/data/anr/traces.txt'
07-11 11:04:35.190: I/dalvikvm(8972): threadid=3: reacting to signal 3
07-11 11:04:35.331: I/dalvikvm(8972): Wrote stack traces to '/data/anr/traces.txt'
07-11 11:04:35.631: I/System.out(8972): hello login
07-11 11:04:35.701: I/dalvikvm(8972): threadid=3: reacting to signal 3
07-11 11:04:35.801: D/AndroidRuntime(8972): Shutting down VM
07-11 11:04:35.801: I/dalvikvm(8972): Wrote stack traces to '/data/anr/traces.txt'
07-11 11:04:35.831: W/dalvikvm(8972): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
07-11 11:04:35.850: E/AndroidRuntime(8972): FATAL EXCEPTION: main
07-11 11:04:35.850: E/AndroidRuntime(8972): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.facbk/com.example.facbk.MainActivity}: com.facebook.FacebookException: Cannot use SessionLoginBehavior SSO_WITH_FALLBACK when com.facebook.LoginActivity is not declared as an activity in AndroidManifest.xml
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.os.Looper.loop(Looper.java:137)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-11 11:04:35.850: E/AndroidRuntime(8972): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 11:04:35.850: E/AndroidRuntime(8972): at java.lang.reflect.Method.invoke(Method.java:511)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-11 11:04:35.850: E/AndroidRuntime(8972): at dalvik.system.NativeStart.main(Native Method)
07-11 11:04:35.850: E/AndroidRuntime(8972): Caused by: com.facebook.FacebookException: Cannot use SessionLoginBehavior SSO_WITH_FALLBACK when com.facebook.LoginActivity is not declared as an activity in AndroidManifest.xml
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.facebook.Session.validateLoginBehavior(Session.java:992)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.facebook.Session.open(Session.java:915)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.facebook.Session.openForRead(Session.java:385)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.parse.auth.FacebookAuthenticationProvider.authenticate(FacebookAuthenticationProvider.java:156)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.parse.ParseUser.authenticateAsync(ParseUser.java:1091)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.parse.ParseUser.logInWithAsync(ParseUser.java:1108)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.parse.ParseUser.logInWithAsync(ParseUser.java:933)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.parse.ParseFacebookUtils.logIn(ParseFacebookUtils.java:338)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.parse.ParseFacebookUtils.logIn(ParseFacebookUtils.java:363)
07-11 11:04:35.850: E/AndroidRuntime(8972): at com.example.facbk.MainActivity.onCreate(MainActivity.java:35)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.Activity.performCreate(Activity.java:4465)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-11 11:04:35.850: E/AndroidRuntime(8972): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-11 11:04:35.850: E/AndroidRuntime(8972): ... 11 more
07-11 11:04:36.190: I/dalvikvm(8972): threadid=3: reacting to signal 3
07-11 11:04:36.230: I/dalvikvm(8972): Wrote stack traces to '/data/anr/traces.txt'
07-11 11:04:36.421: I/dalvikvm(8972): threadid=3: reacting to signal 3
07-11 11:04:36.471: I/dalvikvm(8972): Wrote stack traces to '/data/anr/traces.txt'