It looks like you're filling the entire samples
buffer with the sine wave - if the bufferSize
is not a multiple of the frequency you're generating then you're going to be partially through a wave when the next sample starts playing - that might be what's causing the pops.
You can test this by changing the bufferSize
and seeing if that changes the frequency of the popping. Bigger buffer should mean these sample mismatches happen less often so the popping should be less frequent.
The solution would be to change
audioTrack.write(samples, 0, bufferSize);
to replace bufferSize
with the location in the buffer of the last 0 crossing.