Stopping system

Asked

Viewed 32 times

0

I got the following form of login:

XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".login">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginStart="41dp"
        android:layout_marginLeft="41dp"
        android:layout_marginTop="24dp"
        android:src="@drawable/logoradiosingular"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="42dp"
        tools:layout_editor_absoluteY="50dp" />

    <EditText
        android:id="@+id/txtUsuario"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginTop="175dp"
        android:layout_marginEnd="93dp"
        android:layout_marginRight="93dp"
        android:background="#ccc"
        android:drawableLeft="@drawable/icon_user"
        android:gravity="center_vertical"
        android:padding="5dp"
        android:text="Usuário"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="92dp"
        tools:layout_editor_absoluteY="214dp" />

    <EditText
        android:id="@+id/pwsSenha"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:layout_alignEnd="@+id/imageView"
        android:layout_alignParentBottom="true"
        android:layout_marginEnd="49dp"
        android:layout_marginBottom="219dp"
        android:background="#ccc"
        android:drawableLeft="@drawable/icon_password"
        android:ems="10"
        android:hint="Senha"
        android:inputType="textPassword"
        tools:layout_editor_absoluteX="92dp"
        tools:layout_editor_absoluteY="286dp" />

    <Button
        android:id="@+id/btnLogar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginEnd="148dp"
        android:layout_marginRight="148dp"
        android:layout_marginBottom="143dp"
        android:text="Login"
        android:onClick="logar"
        tools:layout_editor_absoluteX="148dp"
        tools:layout_editor_absoluteY="369dp" />

    <Button
        android:id="@+id/btnCadastrar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="22dp"
        android:layout_marginBottom="20dp"
        android:text="Novo Cadastro"
        tools:layout_editor_absoluteX="4dp"
        tools:layout_editor_absoluteY="458dp" />

</RelativeLayout>

JAVA

package carcleo.com.radiosingular;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class login extends Activity {

    private EditText usuario;
    private EditText senha;

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

        usuario = (EditText)findViewById(R.id.txtUsuario);
        senha = (EditText)findViewById(R.id.txtSenha);

    }


    public void logar (View v) {

        AlertDialog.Builder dlg2 = new AlertDialog.Builder(this);
        dlg2.setTitle("Aviso");
        dlg2.setMessage("Ok até aqui!");


        if(usuario.getText().toString() == null || usuario.getText().toString().equals("")){
            AlertDialog.Builder dlg = new AlertDialog.Builder(this);
            dlg.setTitle("Aviso");
            dlg.setMessage("Usuário não pode estar vazio!");
            usuario.setFocusable(true);
            return;
        }
        if(senha.getText().toString() == null || senha.getText().toString().equals("")){
            AlertDialog.Builder dlg = new AlertDialog.Builder(this);
            dlg.setTitle("Aviso");
            dlg.setMessage("Senha não pode estar vazia!");
            senha.setFocusable(true);
            return;
        }
        if (usuario.getText().toString() != "admi") {
            AlertDialog.Builder dlg = new AlertDialog.Builder(this);
            dlg.setTitle("Aviso");
            dlg.setMessage("Usuário Errado!");
            usuario.setFocusable(true);
            return;
        }
        if (senha.getText().toString() != "senha") {
            AlertDialog.Builder dlg = new AlertDialog.Builder(this);
            dlg.setTitle("Aviso");
            dlg.setMessage("Senha Errada!");
            senha.setFocusable(true);
            return;
        }
        AlertDialog.Builder dlg = new AlertDialog.Builder(this);
        dlg.setTitle("Aviso");
        dlg.setMessage("Tudo Certo");

        Intent intent = new Intent(this, Principal.class);
        startActivity(intent);
    }
}

Well, I’m testing right on Moto G 4 Play by my machine does not hold very well a emulator.

The problem is that when click in the botão de logar, the program for and gives the warning on the screen:

Radio Singular parou
Abrir app novamente?

Where am I going wrong?

  • logcat can answer your question.

  • I’m sorry, I don’t understand your comment. Can you explain better in a reply until so that you can serve someone else? Thank you!

  • logcat, displays which error ended up generating the message that app stopped. Look at this post, to better understand.

  • ah yes. I understand you now. But the error is not of compilation is at runtime. So I did not find in inspector!

  • that is, the logcat does not display any error

  • here is the error: Rearimageractive parameter not found. How to fix?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.