0

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 ?

BigBugCreator
  • 1,009
  • 4
  • 17
  • 34
  • "get `onActivityResult()` in a Fragment" like your question's title or "call `onActivityResult()` from the fragment" as you said in your question's body? Those are not the same :/ – shkschneider May 07 '15 at 13:04
  • 1
    Both, I just need call to the method of the fragment. – BigBugCreator May 07 '15 at 13:06
  • onActivityResult(...) method calls automatically when intent.startActivityForResult called. – Rahul Patidar May 07 '15 at 13:11
  • You can create a `listener` for your fragment and then you call it from the `onActivityResult()`. Doing that you could call whatever fragment which is in execution – Lennon Spirlandelli May 07 '15 at 13:19
  • I tryed with onClickListener in my facebook button, but it doesn´t work becouse I need to get the requestCode, responseCode, intent from ActivityResult – BigBugCreator May 07 '15 at 13:23

0 Answers0