Learn Android reverse from 0 to 1 | write the first Android program

Learn Android reverse from 0 to 1

As the saying goes: "a good memory is better than a bad pen". This series of articles is mainly to record their process of learning Android reverse and the pits they encounter. Thank the books, blogs and the coquettish operations of various bosses referred to in the series of articles.

preface

If you want to be able to reverse development, you must learn positive development. If you don't know positive development, reverse development is not easy to learn. Only when you know positive development, can you learn reverse development again, and go to a higher level. D's all d! No more nonsense! Fuck! Fuck!

1. Configure Android environment

Chicken course: https://www.runoob.com/android/android-tutorial.html

2. Create a blank Android program

Select a blank magic board

After loading and clicking run, you will see an initialization blank interface on the simulator, capitalized with Hello world!

3. Learn about the four components of Android

Chicken course: https://www.runoob.com/android/android-application-components.html

assemblydescribe
ActivitiesDescribes the UI and handles user interaction with the machine screen.
ServicesHandles background operations associated with an application.
Broadcast ReceiversHandles communication between the Android operating system and applications.
Content ProvidersHandle data and database management issues.

4. do a simple login page

Official android documentation: https://developer.android.google.cn/guide/topics/ui/controls/button?hl=en

Click project

Activity found_ main. XML file and switch to setup mode
Drag the box on the left into the page to design the following interface
Write our code in MainActivity, and you can check the usage in the official document for the parts that won't.

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;
import android.widget.EditText;
import android.widget.Button;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    EditText username;
    EditText password;
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        username = (EditText)findViewById(R.id.editTextTextUserNmae);
        password = (EditText)findViewById(R.id.editTextTextPassword);

        btn = (Button)findViewById(R.id.button);
        //https://developer.android.google.cn/guide/topics/ui/controls/button?hl=en#java
        btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // When btn is clicked
                checkUser(username.getText().toString(),password.getText().toString());
            }
        });

    }

    public void checkUser(String username,String password){
        if (username.equals("404nofound")&&password.equals("wojiushimima")) {
            //	makeText(Context context, int resId, int duration)
            //  Make a standard toast that contains only the text from the resource.
            //context 	 Context: the context to use. It is usually your Application or Activity object.
            //resId 	 int: the resource ID of the string resource to use. You can format text.
            //duration 	 int: time to display the message. Whether or value is, or LENGTH_SHORT LENGTH_LONG LENGTH_SHOR TLENGTH_LONG
            Toast.makeText(MainActivity.this, "Login successful", Toast.LENGTH_SHORT).show();
        }else {
            Toast.makeText(MainActivity.this, "Wrong account or password", Toast.LENGTH_SHORT).show();
        }
    }

}

Click Run

Such a simple Android small example is finished, which is used for reference in this paper Teach my brother to learn Android reverse 01 and write the first Android program , brother duck's homework is my next article.

Android code in github: https://github.com/404SpiderMan/Learning-Android-Reverse-from0to1

summary

The above is the content of the first day. This article only briefly introduces a small Android program. More practice is the last word. I encourage you.

Keywords: Android

Added by dominant on Mon, 24 Jan 2022 01:44:06 +0200