I want to open next activity but having following error
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.pc.lovequoteandcalculator/int}; have you declared this activity in your AndroidManifest.xml?
My Manifest.xml is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pc.lovequoteandcalculator">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".lovecalculate" />
<activity android:name=".quoteforlove" />
<activity android:name=".quotestoimpress"></activity>
</application>
And this is how I am starting new activity
val btn = findViewById<View>(R.id.btnlovecal) as Button btn.setOnClickListener {
startActivity(
Intent(this@MainActivity,activity_lovecalculate::class.java)
)
}
Can someone point out what am I missing here?
You seem to calling the wrong activity with the following:
Intent(this@MainActivity,activity_lovecalculate::class.java)
which is trying to call activity_lovecalculate
activity. But you only have:
<activity android:name=".lovecalculate" />
So, try using lovecalculate
with something like this:
val btn = findViewById<View>(R.id.btnlovecal) as Button btn.setOnClickListener {
startActivity(
Intent(this@MainActivity, lovecalculate::class.java)
)
}
PS: Please use a correct coding style for class name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.