As you see Intent
is red and I can't make it fix any idea?
Asked
Active
Viewed 1,162 times
-3

mafortis
- 6,750
- 23
- 130
- 288
-
Have you import the intent class? – Abdul Waheed Jan 28 '21 at 07:41
-
@AbdulWaheed .........yes – mafortis Jan 28 '21 at 07:42
-
use getActivity() instend of "this" Intent(getActivity(),splash2::class.java) – milan pithadia Jan 28 '21 at 08:28
2 Answers
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