I just started in smali and I'm trying to add moveTaskToBack(true) in main activity (smali) but I don't know how to convert it.
Btw here's what I tried:
invoke-virtual {p0, v0}, Landroid/androapp/Main;->moveTaskToBack(Z)Z
Use apktool to decompile
java -jar apktool.jar d <file-to-decompile.apk>
Then edit the smali file where you want to insert the code.
But you have to make sure that at the point where you insert the code v0
already contains the value 1
for true, or you have to set it to 1
but then make sure v0
does not contain a value that is used later:
const/4 v0, 0x0
invoke-virtual {p0, v0}, Landroid/androapp/Main;->moveTaskToBack(Z)Z
Afterwards rebuild the app using apktool.
java -jar apktool.jar b <directory created by apktool>
If apktool succeeds you find the generated apk file in the dist/
subdirectory.
Depending on the APK file that is modified you may have to align the apk using zipalign 4 <modified apk file>
or zipalign -p 4 <modified apk file>
(the latter has to be used in case the app defines extractNativeLibs=false
in it's AndroidManifest.xml
).
Now you have to resign the apk using e.g. apksigner
for Android SDK.