change markerSnippet at google maps on android Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of change markerSnippet at google maps on android without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have an activity called GatherActivity where I have an EditText. The user can input what ever he wants. Now I need the input of that EditText in a different class, called MapActivity. I created an Intent to “put it over” in the other activity. But it doesn’t work like I aspect it. the object/editText is allways a null object, so nothing is displayed as a markerSnippet. Here my Code (GahterActivity) in a method onButtonClick():

public void onButtonClick(View view){

EditText editText_markerSnippet = (EditText) findViewById(R.id.editText_markerSnippet);

Intent intent = new Intent(this, MapActivity.class);
intent.putExtra("markerSnippet", editText_markerSnippet.getText().toString());
}

Code in MapActivity:

Bundle extras = getIntent().getExtras();
    if(extras != null){
        markerSnippet = extras.getParcelable("markerSnippet");
}else{
    markerSnippet = "some extra info about your location"
}

in my marker snippet there is no text. so the else case is not in use here…

Answer

You’re sending a String, but expecting a Parcelable in your activity.

In your MapActivity, change it to:

markerSnippet = extras.getString("markerSnippet");
We are here to answer your question about change markerSnippet at google maps on android - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji