After implementing the following , OnCancel method is being called :
<activity
android:name=".FbLoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_fb_login"
android:theme="@style/FullscreenTheme" >
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="xxxxxxxxxxxxxx"/>
<provider android:authorities="com.facebook.app.FacebookContentProvider456579934439214"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
In the Activity:
public class FbLoginActivity extends Activity {
TextView tvTermsLink;
CallbackManager callbackManager;
String TAG="FbLoginActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_fb_login);
LoginButton loginButton = (LoginButton) findViewById(R.id.authButton);
loginButton.setReadPermissions(Arrays.asList("user_location", "email", "user_friends", "user_birthday", "user_likes", "user_work_history", "user_relationships", "user_relationship_details",
"user_education_history"));
tvTermsLink=(TextView) findViewById(R.id.fbl_tv_termsLink);
tvTermsLink.setText(Html.fromHtml("By logging in you accept the <a href="http://crownit.in/terms">Terms & Conditions</a> "));
tvTermsLink.setMovementMethod(LinkMovementMethod.getInstance());
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException e) {
}
});
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
After prolonged referring the online resources, I am not able to understand whats wrong in the code. Any help will be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…