Android studio:Can't recognize the wav file as the second param to MediaPlayer

Issue

When I use MediaPlayer to play a wav file:

enter image description here

I got a problem:Cannot resolve method ‘create(com.edu.hitsz.aircraftwar.SecondFragment, int)’
I assume that this might because the wav type was wrongly recognized, so I change the associated type do like this answer:

Why does android studio not recognize .wav / .mp3 files

enter image description here

But my problem is still not solved. What’s wrong?

Solution

The first parameter is a context, not a fragment. Use getActivity() instead of this.

Answered By – Gabe Sechan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published