2013-09-02 9 views
0

при размещении звонка, и я показываю уведомление, только значок появляется на панели, и телефон не звонит и не вибрирует.Уведомления о предупреждении о вызове в android?

Как это могло случиться?

мой код:

NotificationManager mNotificationManager = (NotificationManager) getSystemService (Context.NOTIFICATION_SERVICE); 

    int icon = R.drawable.icon; 
    CharSequence tickerText = "Hello"; 
    long when = System.currentTimeMillis(); 

    Notification notification = new Notification (icon, tickerText, when); 

    Context context = getApplicationContext(); 
    CharSequence contentTitle = "My notification"; 
    CharSequence contentText = "My Message"; 
    Intent notificationIntent = new Intent (this, NotificationClic.class); 
    PendingIntent contentIntent = PendingIntent.getActivity (this, 0, notificationIntent, 0); 

    notification.setLatestEventInfo (context, contentTitle, contentText, contentIntent); 
    notification.defaults = Notification.DEFAULT_SOUND; 
    notification.flags | = Notification.FLAG_AUTO_CANCEL; 

    mNotificationManager.notify (1, notification); 

высоко ценим помощь

ответ

0

Попробуйте

Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
notification.setSound(sound); 

Вы должны будете использовать NotificationBuilder построить свой Notification объект, а затем назначить параметры , Вот основной пример:

Notification notification = new NotificationCompat.Builder(ctx) 
      .setContentIntent(pIntent) 
      .setContentTitle("Your Notification Title") 
      .setContentText("Your Notification Text") 
      .setSmallIcon(R.drawable.ic_launcher) 
      .setSound(alarmSound) 
      .build(); 
Смежные вопросы