SHARE
TWEET

Untitled

a guest Jan 12th, 2013 15 Never
  1. mMediaPlayer = new MediaPlayer();
  2. mMediaPlayer = MediaPlayer.create(this, R.raw.mySound);
  3. mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
  4. mMediaPlayer.setLooping(true);  // Set false if you don't want it to loop
  5. mMediaPlayer.start();
  6.        
  7. try {
  8.         Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
  9.         Ringtone ring = RingtoneManager.getRingtone(getApplicationContext(), notification);
  10.         ring.play();
  11.     } catch (Exception e) {}
  12.        
  13. notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notifysnd);
  14. notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE
RAW Paste Data
Top