Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the Android login interface

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to write the Android login interface". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

0x01 Android programming-login interface description

This is what we must learn when learning programming, this time we will not connect to the database to operate. There is no registration interface, just a simple login interface.

Demo is still in accordance with the previous changes. Well, anyway, I will, I will be lazy.

1. Change layout

First of all, a box for the user name.

Then a box for login password.

Then there is a login button.

Preview our interface.

Ugly, make a simple adjustment, the overall code is as follows:

two。 Bind control

Well, I changed name to be like a login interface.

So rebind.

3. Logical writing login.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {if (name.getText (). ToString (). Equals ("zhuzhu") & & Integer.parseInt (ps.getText (). ToString ()) = = 520) {startActivity (new Intent (MainActivity.this,Main2Activity.class)) })

A knowledge point is involved here.

How java String types are converted to int types.

To put it simply:

Integer.parseInt ()

You can change it.

It suddenly occurred to me what if I didn't enter a number. Well, go change the rules.

A line is added here that only allows you to enter numbers.

test

0x02 decompilation analysis

Analysis, many times. Old rules

1. Android Killer

two。 Find the main function

We find the place of logical judgment $1

.class Lcom/example/hanlei/first_demo/MainActivity$1;.super Ljava/lang/Object;.source "MainActivity.java" # interfaces.implements Landroid/view/View$OnClickListener;# annotations.annotation system Ldalvik/annotation/EnclosingMethod; value = Lcom/example/hanlei/first_demo/MainActivity;- > onCreate (Landroid/os/Bundle;) V.end annotation.annotation system Ldalvik/annotation/InnerClass; accessFlags = 0x0 name = null.end annotation# instance fields.field final synthetic this$0:Lcom/example/hanlei/first_demo/MainActivity # direct methods.method constructor (Lcom/example/hanlei/first_demo/MainActivity;) V .locals 0 .param p1, "this$0" # Lcom/example/hanlei/first_demo/MainActivity; .prologue .line 24 iput-object p1, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; invoke-direct {p0}, Ljava/lang/Object -> () V return-void.end method# virtual methods.method public onClick (Landroid/view/View;) V .locals 4 .param p1, "v" # Landroid/view/View; .prologue .line 27 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; # getter for: Lcom/example/hanlei/first_demo/MainActivity;- > name:Landroid/widget/EditText Invoke-static {v0}, Lcom/example/hanlei/first_demo/MainActivity;- > access$000 (Lcom/example/hanlei/first_demo/MainActivity;) Landroid/widget/EditText; move-result-object v0 invoke-virtual {v0}, Landroid/widget/EditText;- > getText () Landroid/text/Editable; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Object;- > toString () Ljava/lang/String Move-result-object v0 const-string v1, "zhuzhu" invoke-virtual {v0, v1}, Ljava/lang/String;- > equals (Ljava/lang/Object;) Z move-result v0 if-eqz v0,: cond_0 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; # getter for: Lcom/example/hanlei/first_demo/MainActivity;- > ps:Landroid/widget/EditText Invoke-static {v0}, Lcom/example/hanlei/first_demo/MainActivity;- > access$100 (Lcom/example/hanlei/first_demo/MainActivity;) Landroid/widget/EditText; move-result-object v0 invoke-virtual {v0}, Landroid/widget/EditText;- > getText () Landroid/text/Editable; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Object;- > toString () Ljava/lang/String; move-result-object v0 invoke-static {v0}, Ljava/lang/Integer -> parseInt (Ljava/lang/String;) I move-result v0 const/16 v1, 0x208 if-ne v0, v1,: cond_0 .line 29 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; new-instance v1, Landroid/content/Intent; iget-object v2, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity Const-class v3, Lcom/example/hanlei/first_demo/Main2Activity; invoke-direct {v1, v2, v3}, Landroid/content/Intent;- > (Landroid/content/Context;Ljava/lang/Class;) V invoke-virtual {v0, v1}, Lcom/example/hanlei/first_demo/MainActivity;- > startActivity (Landroid/content/Intent;) V. line 31: cond_0 return-void.end method3. Key logic part

The key logic is how to judge the login part.

If-eqz v0,: cond_0 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; # getter for: Lcom/example/hanlei/first_demo/MainActivity;- > ps:Landroid/widget/EditText; invoke-static {v0}, Lcom/example/hanlei/first_demo/MainActivity;- > access$100 (Lcom/example/hanlei/first_demo/MainActivity;) Landroid/widget/EditText Move-result-object v0 invoke-virtual {v0}, Landroid/widget/EditText;- > getText () Landroid/text/Editable; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Object;- > toString () Ljava/lang/String; move-result-object v0 invoke-static {v0}, Ljava/lang/Integer;- > parseInt (Ljava/lang/String ) I move-result v0 const/16 v1, 0x208 if-ne v0, v1,: cond_0 .line 29 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; new-instance v1, Landroid/content/Intent; iget-object v2, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity Const-class v3, Lcom/example/hanlei/first_demo/Main2Activity; invoke-direct {v1, v2, v3}, Landroid/content/Intent;- > (Landroid/content/Context;Ljava/lang/Class;) V invoke-virtual {v0, v1}, Lcom/example/hanlei/first_demo/MainActivity;- > startActivity (Landroid/content/Intent;) V

We see two if languages.

The whole logic is to make one judgment first and then another. The first if statement is satisfied, and then the second if statement is satisfied.

This smali code is the statement that we have analyzed many times before, there is nothing difficult, it is very simple.

0x03 violence aesthetics

Let's try to crack it.

Method 1 idea

Since there is an if statement to judge, I deleted the if statement. Programming now looks like this:

Invoke-static {v0}, Lcom/example/hanlei/first_demo/MainActivity;- > access$000 (Lcom/example/hanlei/first_demo/MainActivity;) Landroid/widget/EditText; move-result-object v0 invoke-virtual {v0}, Landroid/widget/EditText;- > getText () Landroid/text/Editable; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Object;- > toString () Ljava/lang/String Move-result-object v0 const-string v1, "zhuzhu" invoke-virtual {v0, v1}, Ljava/lang/String;- > equals (Ljava/lang/Object;) Z move-result v0 here delete if statements iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; # getter for: Lcom/example/hanlei/first_demo/MainActivity;- > ps:Landroid/widget/EditText Invoke-static {v0}, Lcom/example/hanlei/first_demo/MainActivity;- > access$100 (Lcom/example/hanlei/first_demo/MainActivity;) Landroid/widget/EditText; move-result-object v0 invoke-virtual {v0}, Landroid/widget/EditText;- > getText () Landroid/text/Editable; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Object;- > toString () Ljava/lang/String; move-result-object v0 invoke-static {v0}, Ljava/lang/Integer -> parseInt (Ljava/lang/String;) I move-result v0 const/16 v1, 0x208 delete the if statement here. Line 29 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; new-instance v1, Landroid/content/Intent; iget-object v2, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity Const-class v3, Lcom/example/hanlei/first_demo/Main2Activity; invoke-direct {v1, v2, v3}, Landroid/content/Intent;- > (Landroid/content/Context;Ljava/lang/Class;) V invoke-virtual {v0, v1}, Lcom/example/hanlei/first_demo/MainActivity;- > startActivity (Landroid/content/Intent;) V. line 31: cond_0 return-void

Then save it for decompilation.

Installation test

Method 2 thinking

The if statement is not deleted, but I change the logic of the if statement. For example, it was supposed to be equal, but I changed it to unequal and continued to run.

Concrete operation

The first judgment statement is:

If-eqz v0,: cond_0

If-eqz means that if it is 0, jump to cond_0.

Now let's revise it to:

If-nez v0,:cond_0

If-nez means, if it's not 0, jump to cond_0.

The second judgment statement is:

If-ne v0, v1,: cond_0

The meaning of if-ne is if v0! = v1 jumps.

Now we change it to:

If-eq v0, v1,: cond_0

If-eq means to jump if it is equal.

test

The test was successful. I don't want to record any pictures.

Method 3 ideas

Since the last thing we have to do is the content of the second judgment, let's just use the Goto statement to go in directly.

First set up a cond_1

Then goto: cond_1

.method public onClick (Landroid/view/View;) V .locals 4 .param p1, "v" # Landroid/view/View; .prologue .line 27 goto: cond_1 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; # getter for: Lcom/example/hanlei/first_demo/MainActivity;- > name:Landroid/widget/EditText Invoke-static {v0}, Lcom/example/hanlei/first_demo/MainActivity;- > access$000 (Lcom/example/hanlei/first_demo/MainActivity;) Landroid/widget/EditText; move-result-object v0 invoke-virtual {v0}, Landroid/widget/EditText;- > getText () Landroid/text/Editable; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Object;- > toString () Ljava/lang/String Move-result-object v0 const-string v1, "zhuzhu" invoke-virtual {v0, v1}, Ljava/lang/String;- > equals (Ljava/lang/Object;) Z move-result v0 if-eqz v0,: cond_0 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; # getter for: Lcom/example/hanlei/first_demo/MainActivity;- > ps:Landroid/widget/EditText Invoke-static {v0}, Lcom/example/hanlei/first_demo/MainActivity;- > access$100 (Lcom/example/hanlei/first_demo/MainActivity;) Landroid/widget/EditText; move-result-object v0 invoke-virtual {v0}, Landroid/widget/EditText;- > getText () Landroid/text/Editable; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Object;- > toString () Ljava/lang/String; move-result-object v0 invoke-static {v0}, Ljava/lang/Integer -> parseInt (Ljava/lang/String;) I move-result v0 const/16 v1, 0x208 if-ne v0, v1,: cond_0: cond_1 .line 29 iget-object v0, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity; new-instance v1, Landroid/content/Intent; iget-object v2, p0, Lcom/example/hanlei/first_demo/MainActivity$1;- > this$0:Lcom/example/hanlei/first_demo/MainActivity Const-class v3, Lcom/example/hanlei/first_demo/Main2Activity; invoke-direct {v1, v2, v3}, Landroid/content/Intent;- > (Landroid/content/Context;Ljava/lang/Class;) V invoke-virtual {v0, v1}, Lcom/example/hanlei/first_demo/MainActivity;- > startActivity (Landroid/content/Intent;) V. line 31: cond_0 return-void.end method test results

The test was successful.

Concluding remarks

There may be many ways to get around it, so we won't show them all here.

The elegant login idea of 0x04

Since it is login, then there must be a comparison, I just need to know what to compare, I need to output the things that need to be compared, so that we can see if it is better.

Code analysis const-string v1, "zhuzhu" invoke-virtual {v0, v1}, Ljava/lang/String;- > equals (Ljava/lang/Object;) Z move-result v0 if-eqz v0,: cond_0

Obviously, compare v0 with v1, return 1 if it is, return 0 if not

Const/16 v1, 0x208 if-ne v0, v1,: cond_0

Define a v1 register and compare v0 with v1 to see if it is consistent. If so, continue to run down.

0x208 is the hexadecimal form, conversion, we know what our password is, and then in the login output. Of course, this is a visible password, if you access the database, it will become an invisible password, and then you can dynamically debug the password to make an output.

How does 0x05 insert ads? what is advertising?

The great god once said that all things that have nothing to do with games are advertisements, and what we generally say about advertisements is, well, very annoying things.

What is the purpose of placing advertisements?

The main purpose of placing advertisements is

(1) do promotion

(2) can make money

Analysis of the principle of implanted advertisement

Use a carrier to carry the advertisement, and then display it. The techniques used are static layouts or dynamic loading. Let's take a look at the specific operation if the advertisement is implanted.

There are rice advertisements on the market.

There are rice advertisements, anyway, I was cheated for two whole days, nothing was successful, and I was tortured enough, but although I did not produce any results, I did have a deep understanding of rice advertisements. This deceiving thing is angry.

In the end, I just succeeded in one of these things.

Crawl pit

Let's start with the pit I ran into. I hope that time can be saved when someone studies it.

Error:Execution failed for task': processDebugManifest'. > [: YoumiSdk_v7.5.1_2018-01-16:] C:\ Users\ hanlei\ Desktop\ ls\ YoumiAndroidSdk\ demo\ normaldemo\ build\ exploded-aar\ YoumiSdk_v7.5.1_2018-01-16\ AndroidManifest.xml:23:3-29:15: Error: Invalid instruction 'targetApi', valid instructions are: REMOVE,REPLACE,STRICT

See this damn thing, there is no, online search said that the need for a new sdk, but the official website only provides the latest sdk, maybe I didn't find it.

Change sdk decisively.

And the official demo imported into Android Studio can not be used, it is also the same problem.

Solution:

Add this sentence to Androidmanifest.xml, which may be useful.

Redo 1. Create a new demo

two。 Add arr package

3. Add dependencies

4. Apply for ID

5. Initialization information

There was no mercy and something went wrong.

Error:Execution failed for task': app:processDebugManifest'. > [: YoumiSdk_v7.5.1_2018-01-16:] C:\ Users\ hanlei\ Desktop\ ls\ YoumiAndroidSdk\ demo\ demo3\ app\ intermediates\ exploded-aar\ YoumiSdk_v7.5.1_2018-01-16\ AndroidManifest.xml:23:3-29:15: Error: Invalid instruction 'targetApi', valid instructions are: REMOVE,REPLACE,STRICT

Change to the arr version and go on.

Remember to change the configuration file

Sure enough, I changed an arr bag and it was right right away. It was so unfriendly.

Let's go on initializing.

6. Set channel number

7. Permission configuration.

Advertisements can only be run if you configure permissions to scan.

Ps

One thing should be done simultaneously.

I should make a record synchronously in my notebook.

Add v4 package compile 'com.android.support:support-v4:xx.x.x'

The v4:xx.x.x here must be the same as the one above. Look directly at the picture:

Finish writing a call

This is the end of the content of "how to write Android login interface". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report