Не обновляется notif

Ответить
krettt
Сообщения: 6
Зарегистрирован: 08 авг 2013, 22:00

Не обновляется notif

Сообщение krettt » 19 авг 2013, 11:52

Доброго времени суток , столкнулся с проблемой ,что ,после вызова stopSelf и startService ,уведомление перестаёт обновляться с помощью startForeground(); Но если я нажимаю на кнопку в уведомлении ,то оно сразу начинает обновляться.И если я закрываю сервис в активити stopService и потом стартую то обновления происходят .Не обновляется только при stopSelf;

вот код моего notification

Код: Выделить всё

 public Notification createNotification()
    {
        RemoteViews views = new RemoteViews(getPackageName(),R.layout.notif);

        Song song = new Song(tracks[indexCurrentTrack]);

        views.setTextViewText(R.id.notifTitle, song.getTitle());
        views.setTextViewText(R.id.notifArtist, song.getArtist() );
        Bitmap cover = song.getBitmap(this);

        if (cover == null)
        {
            views.setImageViewResource(R.id.notifAlbum, R.drawable.fallback_cover);
        }
        else
        {
            views.setImageViewBitmap(R.id.notifAlbum, cover);
        }
        int playButton = isPlaying ? R.drawable.notif_pause : R.drawable.notif_play;
        views.setImageViewResource(R.id.notifPlay, playButton);

        ComponentName componentName = new ComponentName(this,PlayingService.class);

        Intent intentPlay = new Intent(actionPlay);
        intentPlay.setComponent(componentName);
        views.setOnClickPendingIntent(R.id.notifPlay, PendingIntent.getService(this, 0, intentPlay, 0));

        Intent intentNext = new Intent(actionNext);
        intentNext.setComponent(componentName);
        views.setOnClickPendingIntent(R.id.notifNext, PendingIntent.getService(this, 0, intentNext, 0));

        Intent intentPrevious = new Intent(actionPrevious);
        intentPrevious.setComponent(componentName);
        views.setOnClickPendingIntent(R.id.notifPrevious, PendingIntent.getService(this, 0, intentPrevious, 0));

        Intent intentClose = new Intent(actionClose);
        intentClose.setComponent(componentName);
        views.setOnClickPendingIntent(R.id.notifClose, PendingIntent.getService(this, 0, intentClose, 0));

        Intent intentActivity = new Intent(FullPlaybackActivity.actionReturnFull);
        intentActivity.setClass(this,FullPlaybackActivity.class);
        intentActivity.putExtra(FileSystemActivity.keyMusic,tracks);
        Notification notification = new Notification();
        notification.contentView = views;
        notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
        notification.contentIntent = PendingIntent.getActivity(this,0,intentActivity,0);
        notification.icon =  isPlaying ?  R.drawable.status_icon_pause : R.drawable.status_icon_play;

        return notification;
    }

krettt
Сообщения: 6
Зарегистрирован: 08 авг 2013, 22:00

Re: Не обновляется notif

Сообщение krettt » 19 авг 2013, 22:58

Сам решил проблему ребиндом сервиса , но причина до сих пор не ясна...

Ответить