[英]Redirect activity to Frontpage activity after facebook login
I am trying to accomplish a redirection to a Frontpage activity after facebook login,I have tried this given code but didn't workout yes also tried this link but didn't work out 我尝试在Facebook登录后完成对Frontpage活动的重定向,我已经尝试了给定的代码,但是没有锻炼,还尝试了此链接,但是没有解决
Code from Login 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);
}}
Messages gradle built 消息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.
I have posted the answer with the complete set of coding please feel free to ask me if you find your self with an error 我已经发布了完整的编码答案,请随时问我是否发现自己有错误
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);
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.