title: unable to set push notification sound in android
body: <p>I have created the push notification application, I'm getting the message from GCM services but push notification sound is not working. I need to play sound when I'm getting notification.I have posted my code below anyone help me with this...</p>
  
  <pre><code>//receiver class//
  
  
  import android.app.Activity;
  import android.app.NotificationManager;
  import android.content.ComponentName;
  import android.content.Context;
  import android.content.Intent;
  import android.media.RingtoneManager;
  import android.net.Uri;
  import android.support.v4.content.WakefulBroadcastReceiver;
  import android.widget.Toast;
  
  public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
  
    @Override
    public void onReceive(Context context, Intent intent) 
    {
      ComponentName comp = new ComponentName(context.getPackageName(),GCMNotificationIntentService.class.getName());
  
      startWakefulService(context, (intent.setComponent(comp)));
  
      setResultCode(Activity.RESULT_OK);
  
      generateNotification(context);
  
      System.out.println("received push notification");
  
      Toast.makeText(context,"received notification",Toast.LENGTH_LONG).show();
    }
  
  private void generateNotification(Context context)
  {
      // TODO Auto-generated method stub
      /*NotificationManager mBuilder=(NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
  
      Uri notificationsound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
  
      mBuilder.setSound(notificationsound);
      */
  }
  
  protected void onHandleIntent(Intent intent) {
      // TODO Auto-generated method stub
  
  }
  }
  
  
  
  
  package com.everest.jewellerapp;
  
  import android.app.IntentService;
  import android.app.Notification;
  import android.app.NotificationManager;
  import android.app.PendingIntent;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Color;
  import android.media.RingtoneManager;
  import android.net.Uri;
  import android.os.Bundle;
  import android.os.SystemClock;
  import android.support.v4.app.NotificationCompat;
  import android.util.Log;
  import com.google.android.gms.gcm.GoogleCloudMessaging;
  
  public class GCMNotificationIntentService extends IntentService
  {
  
  
    public static final int NOTIFICATION_ID = 1;
  
    private NotificationManager mNotificationManager;
  
    NotificationCompat.Builder builder;
  
    public GCMNotificationIntentService() 
    {
      super("GcmIntentService");
    }
  
    public static final String TAG = "GCMNotificationIntentService";
  
    @Override
    protected void onHandleIntent(Intent intent) 
    {
      Bundle extras = intent.getExtras();
  
      GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
  
      String messageType = gcm.getMessageType(intent);
  
      if (!extras.isEmpty()) 
      {
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) 
        {
          sendNotification("Send error: " + extras.toString());
        }
        else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) 
        {
          sendNotification("Deleted messages on server: "
              + extras.toString());
        } 
        else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) 
        {
  
          for (int i = 0; i &lt; 3; i++) {
            Log.i(TAG,
                "Working... " + (i + 1) + "/5 @ "
                    + SystemClock.elapsedRealtime());
            try 
            {
              Thread.sleep(5000);
            } 
            catch (InterruptedException e)
            {
            }
  
          }
          Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
  
          sendNotification("Message Received from Google GCM Server: "+ extras.get(Config.MESSAGE_KEY));
  
  
  
          Log.i(TAG, "Received: " + extras.toString());
        }
      }
      GcmBroadcastReceiver.completeWakefulIntent(intent);
    }
  
    private void sendNotification(String msg) 
    {
      Log.d(TAG, "Preparing to send notification...: " + msg);
  
      mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
  
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0,new Intent(this, MainActivity.class), 0);
  
      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
          .setSmallIcon(R.drawable.ic_launcher)
          .setContentTitle("ijeweller")
          .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
          .setContentText(msg);
  
      mBuilder.setContentIntent(contentIntent).setContentTitle("").setContentText("");
      mBuilder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); 
      mBuilder.setLights(Color.RED, 3000, 3000); 
  
  
      Uri notificationsound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
  
      mBuilder.setSound(notificationsound);
  
  
      mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
  
      Log.d(TAG, "Notification sent successfully.");
    }
  }
  </code></pre>
  
  <p>permissions</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  &lt;!-- GCM requires a Google account. --&gt;
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  
  &lt;!-- Keeps the processor from sleeping when a message is received. --&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
  &lt;!-- Creates a custom permission so only this app can receive its messages. --&gt;
  &lt;permission
      android:name="com.everest.jewellerapp.permission.C2D_MESSAGE"
      android:protectionLevel="signature" /&gt;
  
  &lt;uses-permission android:name="com.everest.jewellerapp.permission.C2D_MESSAGE" /&gt;
  
  &lt;!-- This app has permission to register and receive data message. --&gt;
  &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
  
  &lt;!-- Network State Permissions to detect Internet status --&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  
  &lt;!-- Permission to vibrate --&gt;
  &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  
  &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt; 
        &lt;uses-permission android:name="android.permission.CALL_PHONE"/&gt;
        &lt;uses-permission android:name="android.permission.RECEIVE_MMS" /&gt;
        &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
        &lt;uses-permission android:name="android.permission.READ_SMS" /&gt;
  </code></pre>