I am working on Android, and I have implemented Push Notifications feature in my app using GCM.
And my intention is to play a ringtone from app Assets or device Sdcard when only for my Application related push Notification arrivals in the installed device.
Client app– The app which receives the push notification. App server– To understand how to send push notification to the users who have installed your app, you have to create an app server. This server sends the message to the GCM (discussed later) which then transmits it to the client app.
The emulator must enable the Google API for Google Play services. To resolve this issue, the mobile developer must create an emulator that uses Google API as the target OS.
What are push notifications? A push notification is a message that pops up on a mobile device, such as a sports score, an invitation to a flash sale or a coupon for downloading. App publishers can send them at any time, since users don't have to be in the app or using their devices to receive them.
1.Create 1 folder named raw under yourApp/res/
2.Do copy and paste your ringtone in this folder
3.Write the below code when your application notify the notification.!
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With