Код: Выделить всё
intent = Intent(applicationContext, MyActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val pendingIntent = PendingIntent.getActivity(applicationContext, 0, intent,
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE)
notificationBuilder = notificationBuilder
.setContentIntent(pendingIntent)
...
(1) установить анимацию через пакет с ожиданием намерение:
Код: Выделить всё
val animationBundle = ActivityOptions.makeCustomAnimation(
this,
R.anim.slide_in_right, // Animation for new activity entering
R.anim.slide_out_left // Animation for current activity exiting
).toBundle()
val pendingIntent = PendingIntent.getActivity(this, 0, availabilityDealIntent,
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE, animationBundle)
Код: Выделить всё
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, R.anim.slide_in_right, R.anim.slide_out_left, 0)
} else {
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left)
}
Код: Выделить всё
@style/LeftRightAnimation
u/anim/slide_in_right
u/anim/slide_out_left
@anim/slide_in_left
@anim/slide_out_right
Код: Выделить всё
true
@anim/slide_in_right
@anim/slide_out_left
- в манифесте не указан режим запуска.
- не имеет значения, какое действие активно в данный момент, когда я нажимаю на уведомление, анимация никогда не происходит
- не имеет значения, находится ли приложение на переднем плане или в фоновом режиме при нажатии на уведомление
- onCreate() нового действия вызывается только один раз
- анимация работает отлично во всех остальных случаях
Подробнее здесь: https://stackoverflow.com/questions/785 ... tification
Мобильная версия