简体   繁体   English

无法找到明确的活动类,是否已在AndroidManifest.xml中声明了该活动?

[英]Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml?

I want to open next activity but having following error 我想打开下一个活动,但出现以下错误

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.pc.lovequoteandcalculator/int}; android.content.ActivityNotFoundException:无法找到显式的活动类{com.example.pc.lovequoteandcalculator / int}; have you declared this activity in your AndroidManifest.xml? 您是否在AndroidManifest.xml中声明了此活动?

My Manifest.xml is 我的Manifest.xml是

<?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. 试图调用activity_lovecalculate活动。 But you only have: 但是您只有:

<activity android:name=".lovecalculate" />

So, try using lovecalculate with something like this: 因此,尝试使用lovecalculate进行以下操作:

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. PS:请对类名使用正确的编码样式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 屏幕锁定导致无法找到明确的活动类,您是否已在AndroidManifest.xml中声明了该活动? - Screen Locked causing Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml? 无法找到显式活动类 {}; 您是否在 AndroidManifest.xml 中声明了此活动 - Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml 无法找到显式活动 class {}; 你有没有在你的 AndroidManifest.xml 地图中声明这个活动 API 不工作g;(Java ZE846DZDBC9AB870 - Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml Maps API not workingg ;( Java Android Studio? android.content.ActivityNotFoundException:无法找到显式活动 class {您是否在 AndroidManifest.xml 中声明了此活动? - android.content.ActivityNotFoundException: Unable to find explicit activity class { have you declared this activity in your AndroidManifest.xml? android.content.ActivityNotFoundException:无法找到显式活动类; 您是否在 AndroidManifest.xml 中声明了此活动? - android.content.ActivityNotFoundException: Unable to find explicit activity class; have you declared this activity in your AndroidManifest.xml? 切换到另一个活动时出错,无法找到明确的活动类,您是否在 AndroidManifest 中声明了此活动 - Error when switching to another Activity unable to find explicit activity class have you declared this activity in your AndroidManifest Android Studio:无法找到显式活动 class 但活动已在 AndroidManifest.xml 中声明 - Android Studio: Unable to find explicit activity class but activity already declared in AndroidManifest.xml 错误您是否在 AndroidManifest.xml 中声明了此活动? - Error have you declared this activity in your AndroidManifest.xml? 您是否在AndroidManifest.xml中声明了此活动? 登录活动 - Have you declared this activity in your AndroidManifest.xml ? LoginActivity 无法找到明确的活动类。 在 AndroidManifest.xml 中 - Unable to find explicit activity class. in AndroidManifest.xml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM