First, I've spent 2 hours looking for information about this, but I think my problem is a little bit singular. I was looking for "onActivityResult doesn´t call from a Fragment", "set fragment id programatically", "get fragment id", "fragment manager..." and nothing resolved my problem.
fragment class
import android.app.Activity;
import android.content.Intent;
import android.hardware.camera2.params.Face;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.facebook.CallbackManager;
import com.facebook.login.widget.LoginButton;
public class RegisterTabLogin extends Fragment {
private FacebookLogin facebookLogin;
private LoginButton loginButton;
View viewRegisterTabLogin;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) {
viewRegisterTabLogin =inflater.inflate(R.layout.register_tab_login,container,false);
loginButton = (LoginButton) viewRegisterTabLogin.findViewById(R.id.login_button);
return viewRegisterTabLogin;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
facebookLogin = new FacebookLogin(getActivity().getApplicationContext());
facebookLogin.setLoginButton(loginButton);
facebookLogin.startLoginButton();
}
public void clickOnLoginButton(int requestCode, int responseCode, Intent intent){
// never here, I just need call this method:
facebookLogin.startCallBackManager(requestCode, responseCode, intent);
}
}
MainActivity.onActivityResult
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
super.onActivityResult(requestCode, responseCode, intent);
}
I don't know how to call onActivityResult
from the fragment. My activity extends just from ActionBarActivity
, doesn't extend from FragmentActivity
.
I was trying with starActivityForResult, but I need 2 parameters, the first is the intent, in my manifest, I put this:
I think that I dont have to touch this code in the manifest, becouse Facebook gave, if I use startActivityForResult, I will need and intent.
Can anyone help ?