I was unable to locate any specific details about this question, so I'll just shoot it here: Is Android able to customize a push notification sound / vibration so that it will keep ringing/vibrating the phone until that push is opened (read) ? If it is possible, could you please give me a hint of how to make it work?
- you are going to drain lots of Battery and your user's might not like it.hemanth kumar– hemanth kumar2013-08-14 09:32:29 +00:00Commented Aug 14, 2013 at 9:32
- I can understand that, but I'm using this only for emergency, or very important push notifications, leaving user choice to enable it or not.DoruAdryan– DoruAdryan2013-08-14 09:44:31 +00:00Commented Aug 14, 2013 at 9:44
3 Answers
The device can light its LED, play ringtone and so on with configuration of your NoticationManager. They runs just after the push is coming.
NotificationCompat.Builder builder = new NotificationCompat.Builder(_context) .setWhen(System.currentTimeMillis()).setTicker("") .setAutoCancel(true).setSmallIcon(getSmallIconResId()).setLargeIcon(getLargeIconResId(_context)) .setContentIntent(null) .setContentTitle("").setContentText(""); builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); builder.setLights(Color.RED, 3000, 3000); builder.setSound(Uri.parse("")); return builder; If you wanna keep ringtone, your must play ringtone after the push.
http://developer.android.com/reference/android/media/Ringtone.html
3 Comments
First of all you must understand how the PushNotification works. It's a communication channel with client-server. Visually it's a notification like a sms on you're phone. However 2 you're question : Yes it's possible. You can set a vibrate,sound and other parameters of you're notification. You say how? I don't want to duplicate google search results. So google it.
Comments
Yes you can set the vibration and ringtone from the code below. for vibration, you have to add the premission in the manifest.
NotificationCompat.Builder builder = new NotificationCompat.Builder(_context) .setWhen(System.currentTimeMillis()).setTicker("") .setAutoCancel(true).setSmallIcon(getSmallIconResId()); builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); builder.setLights(Color.RED, 3000, 3000); builder.setSound(Uri.parse("")); return builder;