I did a little experiment today. I downloaded a random APK to replace the picture on the home page. The original APK is a static picture. I’m going to replace it with dynamically loaded images from the web. Six steps: 1: decompile the APK using ApkIDE. 2: find the Activity started. 3: modify the resource. 4: write the code to load the image. 5: test. 6: pack and call it a day.
A: unpack
Use tools to unpack the downloaded APK.
;
Two: Find the launch page
First, you should look at androidmanifest.xml to determine which Activity is the first interface.
; The circled area in the picture is marked as the first page to be started when the app is started. Since we want to modify the starting picture, we must start from here. This Activity is called loginActivity, so let’s open it up.
Three: change resources
Before looking at an Activity, we should go to its XML layout to see what’s in it.
Fortunately, I found the image loaded at startup. The area I circled was the image loaded on the home page. We want to change this image. Then you need to load the control with code from the network at startup time. So… Meng made the.. You need to look at the LoginActivity smALI. We first locate the initial control unit. Let’s take a look at the code… In order to add an image display to the home page, I need an image display control in the XML. Notice that there is an ImageView control that loads our web images. When I look at the LoginActivity code, the control is not actually used. Just what I mean…
Given the id of the control, let’s do a search.
Once we get the hexadecimal value of id, we search again.
Good tool use…
This is where the controller is initialized.
const v0, 0x7f0c0085 invoke-virtual {p0, v0}, Lcom/iptv/romance/LoginActivity; ->findViewById(I)Landroid/view/View; move-result-object v0 check-cast v0, Landroid/widget/ImageView; iput-object v0, p0, Lcom/iptv/romance/LoginActivity; ->R:Landroid/widget/ImageView;Copy the code
Very simple, just five sentences: the first sentence: the control’s hexadecimal ID value. Assign to v0. Find the control by id. P0 is the context. Return the found result to v0. Convert an object reference in the V0 register to the specified type. Picture control. R is our imageView control. At this point we have found the control we need to display the image. The next step is to display pictures from the network onto the control. So I developed an imageLoad class to do this.
Four: Write code
; Java generates imageLoad$1$1/imageLoad$1. We use it this way.
; Write the method directly as static, easy to call. The method of loading the image is circled in the figure. Parameter 1: context. Parameter 2: Image object. Upload the control in, download the image and display it directly on the control to complete our work…
Five: Run tests
My Internet is driving me crazy… So feel free to test it out.
Six: packaging
Packaging is packaged directly using the IDE. When packaged, an APK is generated.
As it was
What it looks like now
At this point, the APK is done, but not the loadImage implementation. Very simple.. Download an image and load it onto the control.