I am sure there is something obvious but have not been able to find a solution to this simple problem. The error is in a main activity attempting to start another activity when a user guesses the correct answer:
Error:(85, 23) Unresolved reference: Intent
The code is from the High/Low Android app in the book 'Kotlin Development for Android'.
val intent = Intent("com.example.user.highlow2.CorrectGuessActivity")
startActivity(intent)
The manifest has the following intent-filter for the called activity:
<intent-filter>
<action android:name="com.example.user.highlow2.CorrectGuessActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
The original syntax and suggestions all yielded the same error. The MainActivity needs the following for the Intent to be recognized: import android.content.Intent
Please keep it simple as possible use
val intent = Intent(this,CorrectGuessActivity::class.java)
startActivity(intent)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With