アプリケーションで Parse を介して Facebook 認証を追加する必要があります。https://parse.com/docs/android/guide#users-facebook-usersの指示に従います。しかし、アプリを実行し、[戻る] ボタンを押してからもう一度実行すると、常に次のエラーが発生します。
java.lang.RuntimeException: Unable to start activity ComponentInfo{.AuthActivity}: java.lang.IllegalStateException: Callback already registered for <facebook>: com.parse.ParseFacebookUtils$1@28d04f8f
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.IllegalStateException: Callback already registered for <facebook>: com.parse.ParseFacebookUtils$1@28d04f8f
at com.parse.ParseAuthenticationManager.register(ParseAuthenticationManager.java:35)
at com.parse.ParseUser.registerAuthenticationCallback(ParseUser.java:1094)
at com.parse.ParseFacebookUtils$ParseUserDelegateImpl.registerAuthenticationCallback(ParseFacebookUtils.java:562)
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:109)
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:92)
at .AuthActivity.onCreate(AuthActivity.java:47)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
それが私のアクティビティがどのように見えるかです:
public class AuthActivity extends AppCompatActivity {
…
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ParseFacebookUtils.initialize(this); // crash here
setupEvents();
…
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ParseFacebookUtils.onActivityResult(requestCode, resultCode, data);
}
private void setupEvents() {
findViewById(R.id.fb_login).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loginViaFacebook();
}
});
}
private void loginViaFacebook() {
ParseFacebookUtils.logInWithReadPermissionsInBackground(AuthActivity.this, null, new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
…
}
});
}
}
ここで何が問題なのですか?