2012-08-27 2 views
0

알림이있는 텍스트를 얻을 수 있습니다. 알림이있을 때 나는 소리를 듣고 싶다.알림이있는 소리를들을 수 없습니다.

안드로이드 코드 :

private static void generateNotification(Context context, String message) { 

    long when = System.currentTimeMillis(); 
    NotificationManager notificationManager = (NotificationManager) context 
      .getSystemService(Context.NOTIFICATION_SERVICE); 
    Notification notification = new Notification(R.drawable.ic_launcher, 
      message, when); 

    notification.defaults|= Notification.DEFAULT_SOUND; 
    String title = context.getString(R.string.app_name); 
    Intent notificationIntent = new Intent(context, 
      GCM.class); 
    // set intent so it does not start a new activity 
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP 
      | Intent.FLAG_ACTIVITY_SINGLE_TOP); 
    PendingIntent intent = PendingIntent.getActivity(context, 0, 
      notificationIntent, 0); 
    notification.setLatestEventInfo(context, title, message, intent); 
    notification.flags |= Notification.FLAG_AUTO_CANCEL; 
    notificationManager.notify(0, notification); 


} 
+0

체크 기본값을 작동 바랍니다 .. –

답변

0

다음 코드를 추가, 내가 그것을 ,,가 설정되지 않을 수 있습니다 100 %

  notification.flags = Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL; 
      notification.defaults |= Notification.DEFAULT_SOUND; 
      notification.defaults |= Notification.DEFAULT_LIGHTS;