Shubham Kanodia
Shubham Kanodia

Reputation: 6236

How to pass name of another activity as a parameter to a method in another activity

So I am trying to use ActivityOptionsCompat here

    ActivityOptionsCompat options = 
        ActivityOptionsCompat.makeSceneTransitionAnimation(NoticeViewer.class,
        v,   // The view which starts the transition
        transitionName    // The transitionName of the view we’re transitioning to
        );

The first argument is supposed to be an Activity object, which I'm trying to supply through the relevant class file, but I get the following type conversion error -

Error:(194, 54) error: no suitable method found for makeSceneTransitionAnimation(Class<NoticeViewer>,View,String)
method ActivityOptionsCompat.makeSceneTransitionAnimation(Activity,View,String) is not applicable
(actual argument Class<NoticeViewer> cannot be converted to Activity by method invocation conversion)
method ActivityOptionsCompat.makeSceneTransitionAnimation(Activity,Pair<View,String>...) is not applicable
(actual argument Class<NoticeViewer> cannot be converted to Activity by method invocation conversion)

I'm missing something really simple, but what is it?

Upvotes: 0

Views: 438

Answers (1)

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132982

Use NoticeViewer.this instead of NoticeViewer.class to pass current Activity Context as first parameter :

ActivityOptionsCompat.makeSceneTransitionAnimation(NoticeBoard.this,...)

Upvotes: 2

Related Questions