Gan*_*esh 5 android push-notification ringtone
我正在使用Android,我已经使用GCM在我的应用中实现了推送通知功能.
我的目的是在应用程序相关的推送通知到达已安装的设备时,从应用程序资产或设备Sdcard播放铃声.
1.在yourApp/res/下创建1个名为raw的文件夹
2.将您的铃声复制并粘贴到此文件夹中
3.当您的应用程序发出通知时,请编写以下代码!
SoundPool sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
int iTmp = sp.load(context, R.raw.windows_8_notify, 1); // in 2nd param u have to pass your desire ringtone
sp.play(iTmp, 1, 1, 0, 0, 1);
MediaPlayer mPlayer = MediaPlayer.create(context, R.raw.windows_8_notify); // in 2nd param u have to pass your desire ringtone
//mPlayer.prepare();
mPlayer.start();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
947 次 |
| 最近记录: |