Что не так с AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
 <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication"
        tools:targetApi="31" >
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.MyApplication.NoActionBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <meta-data
                android:name="android.app.lib_name"
                android:value="" />
        </activity>
        <activity
            android:name=".notelayouts"
            android:exported="false" >
            <meta-data
                android:name="android.app.lib_name"
                android:value="" />
        </activity>
    </application>
</manifest>

такая вот ошибка android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.myapplication/int}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared ? код:

val notelayout = Intent(this, R.layout.activity_notelayouts::class.java)
val note = Button(this)
note.setOnClickListener {
    startActivity(notelayout)
}

Ответы (1 шт):

Автор решения: woesss

Для запуска активности явным интентом нужно указать её класс, а не макет и тем более не класс идентификатора ресурса как у вас (это вообще бессмыслица).

val notelayout = Intent(this, notelayouts::class.java)
val note = Button(this)
note.setOnClickListener {
    startActivity(notelayout)
}
→ Ссылка