简体   繁体   English

android.content.ActivityNotFoundException:无法找到显式活动类; 您是否在 AndroidManifest.xml 中声明了此活动?

[英]android.content.ActivityNotFoundException: Unable to find explicit activity class; have you declared this activity in your AndroidManifest.xml?

I'm not understanding the reason for the error, as the "Resultado" class was declared in Manifest.我不明白错误的原因,因为“Resultado”类是在 Manifest 中声明的。 Can anyone help?任何人都可以帮忙吗? Thank you!谢谢!

My Manifest我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uerj.normal">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".Menu_Principal">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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


</application>

</manifest>

Code代码

My code basically consists of a Result activity in order to calculate and display the related results.我的代码基本上由一个 Result 活动组成,以便计算和显示相关结果。

package uerj.normal;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

public class Entrada_Dados extends AppCompatActivity{

    // DECLARANDO AS VARIÁVEIS

    public EditText txt_normal;
    public EditText txt_momento;
    public EditText txt_largura;
    public EditText txt_altura;
    public EditText txt_resistencia_concreto;
    public EditText txt_cobrimento;
    public EditText txt_numero_barras_linha_compressao;
    public Spinner cmb_diametro_barra_compressao;
    public EditText txt_numero_barras_linha_tracao;
    public Spinner cmb_diametro_barra_tracao;
    public String [] diametro_barra = new String[]{"6,3", "8", "10", "12,5", "16", "20", "22", "25", "32", "40"};
    public EditText txt_altura_util;

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

        // RELACIONANDO VARIÁVEIS COM COMPONENTES

        txt_normal = (EditText)findViewById(R.id.txt_normal);
        txt_momento = (EditText)findViewById(R.id.txt_momento);
        txt_largura = (EditText)findViewById(R.id.txt_largura);
        txt_altura = (EditText)findViewById(R.id.txt_altura);
        txt_resistencia_concreto = (EditText)findViewById(R.id.txt_resistencia_concreto);
        txt_cobrimento = (EditText)findViewById(R.id.txt_cobrimento);
        txt_numero_barras_linha_compressao = (EditText)findViewById(R.id.txt_numero_barras_linha_compressao);
        cmb_diametro_barra_compressao = (Spinner)findViewById(R.id.cmb_diametro_barra_compressao);
        txt_numero_barras_linha_tracao = (EditText)findViewById(R.id.txt_numero_barras_linha_tracao);
        cmb_diametro_barra_tracao = (Spinner)findViewById(R.id.cmb_diametro_barra_tracao);
        txt_altura_util = (EditText)findViewById(R.id.txt_altura_util);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, diametro_barra);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        cmb_diametro_barra_compressao.setAdapter(adapter);

        ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, diametro_barra);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        cmb_diametro_barra_tracao.setAdapter(adapter);

        // EVENTO NO BOTÃO

        final Button btn_resultado = (Button) findViewById(R.id.btn_resultado);
        btn_resultado.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                if (txt_normal.getText().toString().equals("")||txt_normal.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha a solicitação Normal Nd");

                else if (txt_momento.getText().toString().equals("")||txt_momento.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha a solicitação Momento Md");

                else if (txt_largura.getText().toString().equals("")||txt_largura.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha a largura da seção");

                else if (txt_altura.getText().toString().equals("")||txt_altura.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha a altura da seção");

                else if (txt_resistencia_concreto.getText().toString().equals("")||txt_resistencia_concreto.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha a resistência do concreto");

                else if (txt_cobrimento.getText().toString().equals("")||txt_cobrimento.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha o cobrimento");

                else if (txt_numero_barras_linha_compressao.getText().toString().equals("")||txt_numero_barras_linha_compressao.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha o número de barras");

                else if (txt_numero_barras_linha_tracao.getText().toString().equals("")||txt_numero_barras_linha_tracao.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha o número de barras");

                else if (txt_altura_util.getText().toString().equals("")||txt_altura_util.getText().toString().equals("."))
                    showError("Campos em branco", "Preencha a altura útil da seção");

                else {

                    Intent it = new Intent (Entrada_Dados.this, Resultado.class);

                    it.putExtra("txt_numero_barras_linha_compressao", txt_numero_barras_linha_compressao.getText().toString());
                    it.putExtra("cmb_diametro_barra_compressao", cmb_diametro_barra_compressao.getSelectedItem().toString());
                    it.putExtra("txt_numero_barras_linha_tracao", txt_numero_barras_linha_tracao.getText().toString());
                    it.putExtra("cmb_diametro_barra_tracao", cmb_diametro_barra_tracao.getSelectedItem().toString());
                    it.putExtra("txt_altura_util", txt_altura_util.getText().toString());
                    it.putExtra("txt_altura", txt_altura.getText().toString());
                    it.putExtra("txt_cobrimento", txt_cobrimento.getText().toString());
                    it.putExtra("txt_largura", txt_largura.getText().toString());
                    it.putExtra("txt_resistencia_concreto", txt_resistencia_concreto.getText().toString());

                    startActivity(it);

                }

            }
        });

    }

    private void showError(String title, String err){
        AlertDialog.Builder builder = new AlertDialog.Builder(this);

        builder.setTitle(title);
        builder.setMessage(err);

        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
            }
        });

        AlertDialog alert = builder.create();
        alert.show();
    }

}

Error错误

在此处输入图片说明

Maybe its some code wrong here in the manifest也许清单中的某些代码有误

...
<activity android:name=".Entrada_Dados">
<activity android:name=".Resultado" />
</activity>

Shouldn't it be like this?不应该是这样吗?

...
<activity android:name=".Entrada_Dados"/>
<activity android:name=".Resultado" />

暂无
暂无

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

相关问题 android.content.ActivityNotFoundException:无法找到显式活动 class {您是否在 AndroidManifest.xml 中声明了此活动? - android.content.ActivityNotFoundException: 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? 屏幕锁定导致无法找到明确的活动类,您是否已在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:无法在Android中找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class in Android android.content.ActivityNotFoundException:无法找到明确的活动类 - android.content.ActivityNotFoundException: Unable to find explicit activity class Android Studio:无法找到显式活动 class 但活动已在 AndroidManifest.xml 中声明 - Android Studio: Unable to find explicit activity class but activity already declared in AndroidManifest.xml 切换到另一个活动时出错,无法找到明确的活动类,您是否在 AndroidManifest 中声明了此活动 - Error when switching to another Activity unable to find explicit activity class have you declared this activity in your AndroidManifest ActivityNotFoundException:无法找到显式活动类GoogleDriveProxeyActivity是否已声明此内容 - ActivityNotFoundException: Unable to find explicit activity class GoogleDriveProxeyActivity have you declared this
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM