Note that there are some explanatory texts on larger screens.

plurals
  1. POplay sound when EditText is changed - android
    primarykey
    data
    text
    <p><br> i want my application to play a sound whenever the user makes an input the EditText field. Hopefully this will create the illusion that the keyboard makes the sound whenever a key is pressed.</p> <p>My code for this specific event lookes like this:</p> <pre><code>package com.textField.android; </code></pre> <p>public class textField extends Activity {</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final EditText edittext = (EditText) findViewById(R.id.edittext); final MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.pistol); edittext.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { mp.start(); mp.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.release(); } }); } </code></pre> <p>}); } }</p> <p>I can install and open the application just fine, and i can enter ONE letter and it plays the sound, but when pressing a second letter the application crashes. I don't know what's wrong. Rotating my device plays the sound aswell no matter how many times i do it. So when rotating back it plays the sound again. But then pressing a key the application crashes WITHOUT playing the sound.<br> Can someone help me get this right? That would be very much appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload