Home > Software design >  android studio page intent eroor
android studio page intent eroor

Time:08-07

I'm trying to switch to another screen using intent, but the app stops working when the button works.The following error code appears: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.webtoon, PID: 27184 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.webtoon/com.example.webtoon.naver}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2115) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1762) at android.app.Activity.startActivityForResult(Activity.java:5407) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597) at android.app.Activity.startActivityForResult(Activity.java:5365) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:583) at android.app.Activity.startActivity(Activity.java:5751) at android.app.Activity.startActivity(Activity.java:5704) at com.example.webtoon.MainActivity$1.onClick(MainActivity.java:24) at android.view.View.performClick(View.java:7455) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1194) at android.view.View.performClickInternal(View.java:7432) at android.view.View.access$3700(View.java:835) at android.view.View$PerformClick.run(View.java:28810) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) W/System: A resource failed to call close. I/Process: Sending signal. PID: 27184 SIG: 9

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="horizontal">

    <Button
        android:id="@ id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="네이버" />

</LinearLayout>

MainActivity.java

package com.example.webtoon;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn = findViewById(R.id.btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this , naver.class);
                startActivity(intent);
            }
        });

    }
}

CodePudding user response:

Activities must always start with a capital letter.

For Example:

naver.java - Naver.java

CodePudding user response:

You have to declare naver activity in the manifest file

  • Related