Take 1

In the first example, we have a basic login screen asking for username, password, and email address (see Listing 3-3). We’re going to show how to check that they’re not empty and then throw up an alert dialog. If you don’t enter any data, then the alert dialog pops up (see line 44).

Listing 3-3 Validate text fields

package com.riis.login;import android.os.Bundle;import android.app.Activity;import android.view.View;import android.widget.Button;import android.widget.EditText;public class LoginActivity extends Activity {    private Button loginButton;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.login_screen);

Get Bulletproof Android™: Practical Advice for Building Secure Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.