-3

one

As you see Intent is red and I can't make it fix any idea?

mafortis
  • 6,750
  • 23
  • 130
  • 288

2 Answers2

2

make use of requireContext() instead of this inside fragments

val intent = Intent (requireContext(), foo::class.java)
AlexTa
  • 5,133
  • 3
  • 29
  • 46
a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
0

You are using it in Fragment,so use context instead of this context?.let{ nonNullContext -> val intent = Intent(nonNullContext, splash2::class.java) }

Rajan Kali
  • 12,627
  • 3
  • 25
  • 37
  • Don't do it like this, this is bad and leads to crashing, forcing optional context to be non nullable, context can be null in case if activity is destroyed, wrap it with context null check if so, or with context?.let {... – mmmatey Jan 28 '21 at 07:46