how to play sound in android <p>I want to play music in my app when application starts. I tried many codes but nothing is working for me and i'm not getting any error.Can somebody please help me regarding this issue.Thanks in advance.</p> <pre><code>public class Login extends Activity { EditText edName, edPassword; String userName,password; MediaPlayer mp; @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); mp = MediaPlayer.create(getApplicationContext(), R.raw.startsound); ActionBar actionBar = getActionBar(); actionBar.hide(); edName = (EditText) findViewById(R.id.editText1); edPassword = (EditText) findViewById(R.id.editText2); mp.start(); } public void SignInClick(View V) { userName = edName.getText().toString(); password = edPassword.getText().toString(); if (userName.equals("")) { Toast.makeText(Login.this, "Username is empty", Toast.LENGTH_LONG).show();} else if (password.equals("")) { Toast.makeText(Login.this, "Password is empty", Toast.LENGTH_LONG).show(); } else { Intent intent=new Intent(Login.this,Home.class); startActivity(intent); } </code></pre> <p>}</p>