3

I have an enum defined in a Fragment companion object:

enum class Channel {
    TAG_FRIENDS, CHALLENGE_INVITE, COMMITMENT_INVITE
}

Normaly I'll access it from another Kotlin class like that:

MyFragment.Companion.Channel.TAG_FRIENDS

How would I access it from a Java class? The Channel enum doesn't seem to be accessable...

3
  • 3
    Enums do not need to be part of companion object. Commented Oct 2, 2018 at 13:20
  • 1
    MyFragment.INSTANCE? In any case as suggested by Enzokie I would move the enum to its own separate class outside of fragment. Commented Oct 2, 2018 at 13:23
  • 1
    Yes, just moved it out of the companion object, and the enum is now accessable. Thanks for reminding me of something I should have thought of myself :-) Commented Oct 2, 2018 at 13:27

1 Answer 1

7

Just in case anyone still need this:

 Channel.TAG_FRIENDS.getValue()
Sign up to request clarification or add additional context in comments.

1 Comment

getValue() is not present in Java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.