GCM Android - Continuously Hear Sound And Vibrate When Received Notification
I push notification from GCM Server to all clients. Continuously hear sound and vibrate until I pull down the notification bar. Here's my code: private static void generateNotifi
Solution 1:
Use following code
NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
Intent m_intent = new Intent(this,MainAcicity.class);
m_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, m_intent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder mBuilder = (Builder) new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setContentTitle(getString(R.string.app_name)).setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg).setAutoCancel(true).setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
Post a Comment for "GCM Android - Continuously Hear Sound And Vibrate When Received Notification"