2016-07-05 5 views
0

通知のiconIndex = 0の場合、配列の0の位置の名前を探し、アイコンの名前である "ic_alert"を返します。このアイコンが選択されている場合にのみしかし、それはisPlaySound()がtrue、とても奇妙...その他のアイコンは、私はこの問題を持っていない特定のアイコンが選択されたときにAndroidが通知音を無視する

public class AlarmReceiver extends BroadcastReceiver 
{ 
@Override 
public void onReceive(Context context, Intent intent) 
{ 
    Log.e("ALARMRECEIVER","ONRECEIVE"); 

    //Create a notification 
    long notificationId = intent.getLongExtra("id", -1); 

    if(notificationId == -1) 
    { 
     Log.e("AlarmReceiver","id went missing"); 
    } 
    else 
    { 
     NotificationRepository repository = NotificationRepository.getInstance(context); 
     Notification notification = repository.getNotification(notificationId); 


     if(notification != null) 
     { 

      String[] icons = context.getResources().getStringArray(R.array.icons); 
      int iconId = context.getResources().getIdentifier(context.getPackageName() 
        + ":drawable/" + icons[notification.getIconIndex()], null, null); 


      String icon = icons[notification.getIconIndex()]; 

      //create the android notification 
      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) 
        .setSmallIcon(iconId) 
        .setContentTitle(notification.getTitle()) 
        .setContentText(notification.getSubtitle()) 
        .setColor(ContextCompat.getColor(context, R.color.colorPrimary)); 

      if(notification.isPlaySound()) 
      { 
       mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); 
       Log.e("ALARMRECEIVER", "SOUND"); 
      } 
      else Log.e("ALARMRECEIVER","NO SOUND"); 

      if (notification.isVibrate()) 
      { 
       mBuilder.setVibrate(new long[]{1000, 1000}); 
      } 

      NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
      // mId allows you to update the notification later on. 
      mNotificationManager.notify((int) notificationId, mBuilder.build()); 
      //Delete the notification from the database 
      repository.removeNotification(notificationId); 

      Intent i = new Intent("dvanack.gmail.com.NOTIFY"); 
      context.sendBroadcast(i); 
      Log.w("ONRECEIVE","ENDED"); 
     } 
+0

Androidのバグかもしれません – PrisonMike

+0

私はそれを解決しました。 – PrisonMike

+0

@XaverKapeller実際には、Cyanogenmodを実行している時間の99%、正当にAndroidを責めている時間の99%ですが、それがAndroidの特定の解釈であることを決して忘れてはいけません。これがCyanogenmodに対して作られていたことが最初に述べられていたなら、誰もその主張に疑問を呈していないでしょう。 – LoungeKatt

答えて

0

細かい作業に戻っても、通知音を再生したくありませんOne PlusがCyanogenmodを実行しているデバイス以外のデバイスでは、これはアップデートで翌日に修正されました...

関連する問題