Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 12th, 2013  |  syntax: None  |  size: 0.66 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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