Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

erro ao mudar o arquivo manifest, trocando o intent-filter para outra activity

Logo no primeiro exemplo, após criar o FormularioActivity e mudar o arquivo manifest , aparece o seguinte erro:

Error running 'ListaAlunosActivity': The activity must be exported or contain an intent-filter.

segue abaixo os códigos feitos:

-----Activity_Formulario--------

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Nome"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Endereço"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Telefone"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Site"/>

    <RatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:numStars="5"
        android:max="10"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Salvar"
        android:id="@+id/formulario_salvar"/>

</LinearLayout>
</ScrollView>

-----FormularioActivity------

package br.com.example.rubens.teste;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class FormularioActivity extends AppCompatActivity {

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

        Button salvar = (Button) findViewById(R.id.formulario_salvar);

        salvar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(FormularioActivity.this,
                "Aluno salvo com sucesso!",Toast.LENGTH_SHORT).show();
            }
        });
    }
}

-------Manifest--------

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

    <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=".ListaAlunosActivity">
        </activity>
        <activity android:name=".FormularioActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
3 respostas

Veja se não está faltando a tag:

<intent-filter>
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
solução!

percebi o que estava dando errado, quando executava no "play" ou pelo atalho, estava tentando executar a activity anterior, por isso o erro!!

Ah não , pera. To vendo ela agora...

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software