DoruAdryan
DoruAdryan

Reputation: 1334

Push Notification Android

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?

Upvotes: 0

Views: 1589

Answers (3)

Aman Gupta
Aman Gupta

Reputation: 11

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;

Upvotes: 0

TeeTracker
TeeTracker

Reputation: 7350

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

Upvotes: 2

user2558337
user2558337

Reputation:

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.

Upvotes: 1

Related Questions