I'll try to be as clear as possible :) I would like to add an activity (let's call it X not to do confusions) to an app in order to do this when the app start :
- First of all, start my activity X and show the layout that contains a button.
- The OnClickListener of the button starts the main activity of the original app.
I have the activity X in an eclypse project, so i can turn my java files to smali. I have the app in smali files + a yml file (by backsmaling).
How can i turn the main activity of the app to a normal activity ? How can i add my activity X to the app ? Which folder of the smali folder ? Do I need to change something in the yml file ? What happens for the xml files ?
Any kind of help will be very appreciated ! :)
Editing the smali files is hard & it's kind of not inteded that you can add buttons to existing activities that way. smali is an assemly-like language that allows for some debugging but is more or less equivalent to the android dalvik bytecode.
You can however wrap apps with different start activites since that doesn't require changes in the apps. It's even automatable and abused by shady 3rd party marketplaces to put malware into the launch activity of other apps.
If you wanted to do that on your own you could probably do it like:
apktool
into smali + resources.apktool
to build an apk.Some important steps in between:
Your new X Activity needs to call
startActivity
using anIntent
setup from Strings since you don't have .class files you could compile against. You'll obviously need to know package and class names of the other app starting activity. Apart from that, just make it the way you'd do any Activity with buttons.The merging of two decompiled apps is mostly simple copy & paste. Copy over the
src
folder, nothing should conflict here. For theres
folder you'll need to know what resources you need, but you can mostly just copy them. For layouts and other named resources make sure not to use conflicting names in your X activity project in the first place. To "merge" 2strings.xml
files just rename one of them, the filename should be irrelevant.Most importantly merge the
AndroidManifest.xml
. You'll need to add your X activity, including the"android.intent.category.LAUNCHER" / ...MAIN
intent filter. That's what determines which activity can be started directly from the launcher. Also remove the filter from the other start activity that should no longer be started.Rebuild an apk and that's it.
Note: I didn't test this in details. I assume it works though :)