0

I'm new in android development and I have an issue with simple string in an intent. I create an Intent in a fragment to launch a new activity. I have no error but I can't put a string through the intent. Here is my code :

public class AboutFragment extends Fragment {

     private static Context mContext;

I have this in the onCreateView method :

     mContext = this.getContext();

This method in the same class

public static void openModalPolicy() {
    Intent intent = new Intent(mContext, ModalActivity.class);
    intent.putExtra("section", "policy");
    mContext.startActivity(intent);
}

And in my new activity :

        String section = this.getIntent().getStringExtra("section");

So the problem is that section is never equal to "policy" If someone can help me :) Have a good day !

1 Answers1

0

Just to be sure, you are using section.equals("policy") for your equality check. Not section == "policy". Right?

Check out this post for more information: How do I compare strings in Java?

Community
  • 1
  • 1
Distwo
  • 11,569
  • 8
  • 42
  • 65