gpt4 book ai didi

java - Facebook 登录后将 Activity 重定向到 Frontpage Activity

转载 作者:行者123 更新时间:2023-12-01 10:19:36 28 4
gpt4 key购买 nike

我试图在 Facebook 登录后完成到 Frontpage Activity 的重定向,我已经尝试过这个给定的代码,但没有锻炼是的,也尝试过这个link但没有解决
登录 Activity 的代码。

public  class login extends FragmentActivity {


private boolean isMainLobbyStarted = false;

CallbackManager callbackManager;
private LoginButton loginButton;
private loginResult loginResult;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this.getApplicationContext());
setContentView(R.layout.activity_login);


public void onSuccess(LoginResult loginResult) {
System.out.println("onSuccess");
Intent mainLobby = new Intent(login.this, Frontpage.class);
if(!isMainLobbyStarted) {
startActivity(mainLobby);
isMainLobbeyStarted = true;
}

}




@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}}

消息gradle构建

Error:(54, 2) error: reached end of file while parsing
Error:(35, 9) error: illegal start of expression
Error:(35, 16) error: illegal start of expression
Error:(35, 30) error: ';' expected
Error:(35, 54) error: ';' expected
Error:(49, 36) error: ';' expected
Error:(49, 53) error: <identifier> expected
Error:(49, 58) error: not a statement
Error:(49, 68) error: ';' expected
Error:(49, 81) error: ';' expected
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.

最佳答案

我已经发布了带有完整编码的答案,如果您发现自己有错误,请随时询问我

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;

public class login extends FragmentActivity {

CallbackManager callbackManager;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this.getApplicationContext());
setContentView(R.layout.activity_login);

callbackManager = CallbackManager.Factory.create();

LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Intent intent = new Intent(login.this, Frontpage.class);
startActivity(intent);
// App code
}

@Override
public void onCancel() {
// App code
}

@Override
public void onError(FacebookException exception) {
// App code
}
});
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}

}

关于java - Facebook 登录后将 Activity 重定向到 Frontpage Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35691416/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com