My two come back.
So we have talked about invoke direct, which is regarding to private and public methods.
We have talked about invoke Volterra, which is regarding to public methods.
The only one that's missing are aesthetic methods right now.
So let's have a look here.
We have some code so we can see we've got now not player class, we've got a level class, we've got
aesthetic value level and we've got this method next level.
This next level increases the static value over here.
Okay, if we call this method, it looks like this.
We do not have to create an instance for this.
So we simply take the class name, which is level.
Then we add this dot and the method name next level.
And the nice thing about this one is we do not need to fill in register with an instance to call this
so we can call this wherever we want in our application.
Static methods are super awesome and they are also not hot.
So let's have a look into the smiley part regarding to a static method.
Okay, so here we have within our main activity, we can see this on the on create and we do not care
about this one, this one, this one and this one.
All we do care about is this one over here, line 17.
If you want to call an static method, we simply use invoke static.
And in case we do not have any parameters, then we also do not need an Yeah register for this because
we do not have in this register in there by having no parameters we simply leave those curly brackets
empty comma, capital L our type reference level then dot next level and that's all we can use this
wherever we like in our application code and we can do really amazing stuff with this.
And this is what we do in the next couple of videos.
I've prepared a lot of applications which we are going to heck, some of them are kind of easy because
we can simply get the information out of the Java code, but some of them also use the indica, the
native development kit.
Therefore the information are stored in the C C++ code and these one are not that easy to analyze,
but having the ability to call the static methods, we use this to fetch out the important informations,
but before we do this, let's have a look into an practical exercise right now.
Okay, so here we are back at the Ubuntu VM.
Let's do some practical exercise on this.
This was the last example.
Now let's create a new static method, public static void set, invisible
system print line.
Now we are invisible.
Okay, let's build this application.
Okay, let's decompile this static and now we do the same again.
So we take our code and we will execute the static method without implementing it in our application
over here.
So here we can see we have introduced it here in our player class, but we didn't call it here and we
will insert it right now at this point.
So we opened this aesthetic smartglasses to with Visual Studio code.
All right.
And then we go into our main activity, and this time we do not have a method to copy from.
So we have to write it on our own main activity.
There we go.
Okay.
So at this point over here, we want to call.
Let's see.
You want to call it player dot set.
Invisible?
Yes.
Okay.
And this one is from type.
What?
So if you want to call a static method, let's look it up.
Invoke static.
Invokes the static method with parameters.
So invoke static curly brackets.
Then we have our parameters and the method call.
All right, so we've got invoke static.
This time we do not have the parameter and we also have a static method.
Therefore, we also do not need in this instance.
Then we still need our type reference.
Which static method we want to call?
Let's assume we've got several classes with the method name set invisible.
This is absolutely no problem because.
Yeah, we've got the class reference for this.
I will show this real quick.
So new Java class, let's call this test within here.
We can also define a new method.
Set invisible.
Return.
What?
This is also a public static method.
And we are returning.
What?
Let's check this.
Yes.
This is the method name and let's see.
Okay,
so now we've got two methods.
Both are named set invisible within the test class and within the player class over here.
Therefore, it's absolutely necessary to give our type reference on which class we are we are acting
on so which method in which class we are using.
Therefore we need column packing smarty three player type definition ends.
We've got still our reference dot because we are calling player dot set invisible and now we simply
just need a prototype of our function.
So set invisible, no parameters, return type void.
And that's it.
This is how we can call a static method.
And yeah, the nice thing is we do not have an object over here, so let's assume we wouldn't have this
object here.
This one.
Sorry, this one.
You know what?
Yeah.
Let's simply delete this.
So why not?
Okay, so we do not have an object right now, and it is now completely different regarding to our application
code over here.
But it doesn't really matter.
Maybe I delete this one real quick.
Okay.
This is our application code.
We create a new player object and we increase the power.
But now we have removed this.
And now we are calling player dot set invisible.
And you see it's working.
So there's no error or things like this because we can call static methods without having an object.
This is why we have a static method.
Okay, so let's get back to the original code, this one over here.
And yes, so first we installed this application.
We tested real quick.
Then we build our application over here and see if we know if our patch has been applied correctly.
And that's all.
This is how we can call static methods.
And yeah, we can call this method wherever we like, so we can simply put this into every function
or class.
We want to execute this right now.
Okay, so let's get back.
First, let's check this application code here.
Seems like not connected.
All right.
This seems to be our old version.
Yes.
We've got a lot of level ups over here.
Let's uninstall this.
Well, Lady B is missing.
And now we installed this application.
All right.
And we can see, okay, I should have cleaned the locket before because.
Yeah, it's now a little bit it's a little bit tricky.
So AdBlock at their C, let's start this app once again.
All right.
We can see we create a new object and our power level is 900.
Exactly what's in there?
Okay.
So let's pay back the other application, this one here and yeah, install it and see if we have removed
our object reference and if we can call this method over here.
So I see you in a few moments.
By the way, I've got this following error right now and this is because I leave this comment in.
So if you patch Smiley, maybe do not write these comments in.
So then, yeah, you can avoid errors like this because having those comments, it's not valid.
Smiley syntax.
That's our screen.
Any B islands dot com pecking smiley.
Three adb a logcat.
C so we clean the logcat output.
Now we install our new version and we also enable the lock that
we grab for system out.
And now, without any drama, simply just open it.
All right.
Now we are invisible and we can see the method codes or the print lines regarding to the object itself
has gone.
So we have successfully patched this application.
Yeah.
Like we wanted to have.
Let's open this with the query quick to verify this.
Income is my only three main activity.
There we go.
Exactly what we wanted to have.
So we have written our own static method right now into this app.
All right, so in the next section, we will use this approach.
So we will use static methods to print out certain debug statements or, for example, to print out
certain important values.
And we have a lot of applications where we practice on and then we get finally back into our space planning
application because then we have learned everything we need to know about patching smartly.
And yeah, we can modify this application in the way we like to have it.
We can make our player invisible, invincible.
We can deactivate the collision system, we can deactivate alien behavior, we can add new aliens,
we can yell at multiple shots, block, file, right, set fire rights, all this amazing stuff.
So we have a little bit of theory, but then we've got tons of practical exercise left and this will
be the most fun part of this course until we get to the free section, because there we also have some
fun again when we write our own trainer.
Okay, but before we hype up too much, yeah, we have to do the theory part first.
Okay.
The last thing I want to mention regarding two static methods is if you have some parameters in there,
for example, two integers, then we need to set up the register of course first.
So this is the same regarding to all methods we need to prepare the registers or the parameters.
In this case we could simply write const we want zero x ten const me two and zero x 16.
Okay, so in this way we can set up those values and yeah, we have to take care that we do not override
existing registers and things like this.
But we will do this also for more complex objects in the practical exercises, and that's all for now.
All right.
So I see you in the next video.