title: How to pass values from Fragment to Activity
body: <p>I am new in Android Development. I am trying to pass values from fragment to activity, but after so many tries I am unable to get the answer...</p>
  
  <p>This is my Fragment :</p>
  
  <pre class="lang-java prettyprint-override"><code>public OtpGentation(int OTP)
  {
      this.OTP =OTP;
  }
  public OtpGentation(String number1, String email1, String password)
  {
      number = number1;
      mail = email1;
      pass = password;
  }
  
  public OtpGentation() {
  
  
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
  {
      rootview = inflater.inflate(R.layout.otp, container, false);
      Bundle bundle = getArguments();
  
      new OTPAsyncManager().execute();
  
      etxotp =(EditText)rootview.findViewById(R.id.etxotp);
      btnNext = (Button) rootview.findViewById(R.id.nextToOTP);
      btnCancel =(Button) rootview.findViewById(R.id.cancel);
  
      //etxotp.setText(OTP);
      btnNext.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view)
          {
  
              if (etxotp.getText().toString().equals(""))
              {
                  Toast.makeText(getContext(), "Please Enter OTP ", Toast.LENGTH_SHORT).show();
  
              }
              else
              {
                  int enteredOtp = Integer.parseInt(etxotp.getText().toString());
                  if (enteredOtp ==OTP)
                  {
  
                      Toast.makeText(getContext(), "OTP Matched", Toast.LENGTH_SHORT).show();
                      Bundle bun = new Bundle();
                      bun.putString("no",number);
                      bun.putString("ma",mail);
                      bun.putString("pa",pass);
                      Intent subintent = new Intent(getContext(),SubmitRegistration.class);
                      subintent.putExtras(bun);
                      startActivity(subintent);
  
  
  
                  }
                  else
                  {
                      Toast.makeText(getContext(), "Please Enter Correct OTP ", Toast.LENGTH_SHORT).show();
                  }
  
              }
  
  
          }
      });
      btnCancel.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view)
          {
  
              fragmentManager = getActivity().getSupportFragmentManager();
              HomeScreen fragmentOne = new HomeScreen();
  
              fragmentManager
                      .beginTransaction()
                      .setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
                      .replace(R.id.content_frame, fragmentOne)
                      .addToBackStack("")
                      .commit();
  
          }
      });
  
  
      return rootview;
  }
  </code></pre>
  
  <p>And this is the class where I want to pass values</p>