0
1I’ve been having a question for a while. I want to pass a value of a activity
for a fragment
, however, the error when opening the fragment
to be specific when receiving this value, I believe.
This is how Seto:
estab = "academia";
MapsFragment_Estab mapsFragment_estab = new MapsFragment_Estab();
Bundle academia = new Bundle();
academia.putString("CoordAcademy", estab);
mapsFragment_estab.setArguments(academia);
And this is how I get on fragment
:
String CoordAcademy = getArguments().getString("CoordAcademy");
[]
With prints, hardly anyone will help you. Instead post the code itself. See: How not to ask
– Zulian
I get it, I’m new around here. I get it, vlw =D.
– Pablo Vasconcelos
Are you putting the
String CoordAcademy = getArguments().getString("CoordAcademy");
within the methodonCreateView()
? Post the whole method. If possible add the error message as well.– Zulian
Error in my map Fragment in onCreate method.
– Pablo Vasconcelos
You would be able to post the error message that appears in your
Log
, at the end of the question? Because at first the syntax is correct.– Zulian
Caused by: java.lang.Nullpointerexception: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null Object Reference At Fragments.Mapsfragment_estab.onCreate(Mapsfragment_estab.java:27)
– Pablo Vasconcelos
Estou repostando o Oncreate sem os meus comments pra ficar mais limpo: public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);

 

 String CoordAcademy = getArguments(). getString("Coordacademy"); getMapAsync(this); }
– Pablo Vasconcelos
I printed the mistakes, above. Already, I thank the attention.
– Pablo Vasconcelos