Jump to content

GET A POPUP START MESSAGE IN A MOD {{TUTORIAL}}


Sysadmin
 Share

Recommended Posts

  • Administrators
 

Normally i will put a start up message on my modded game. You can do so by adding:

Code:
const/4 v0, 0x1
    const-string v1, "YOUR TEXT HERE"
    invoke-static {p0, v1, v0}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;
    move-result-object v0
    invoke-virtual {v0}, Landroid/widget/Toast;->show()V

at OnCreate() of the main launch activity. To find out where is the launcher activity, you can refer to file: AndroidManifest.xml (created after apktool d).
example in soulcraft AndroidManifest.xml

Code:
<activity android:icon="@drawable/icon" android:name="delta.platforms.monodroid.downloader.DownloaderActivity" android:launchMode="singleTask" android:screenOrientation="landscape" android:configChanges="keyboard|keyboardHidden|orientation" android:noHistory="true">
<intent-filter>
  <action android:name="android.intent.action.MAIN" />
  <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Just look for that keyword "LAUNCHER", then above is it's android activity name, in this case it is "delta.platforms.monodroid.downloader.DownloaderActivity", so the main starting OnCreate is in \smali\delta\platforms\monodroid\downloader\DownloaderActivity.xml

Code:
.method public onCreate(Landroid/os/Bundle;)V
    .locals 0
    .parameter

    .prologue
    .line 31
    invoke-direct {p0, p1}, Ldelta/platforms/monodroid/downloader/DownloaderActivity;->n_onCreate(Landroid/os/Bundle;)V

    .line 32
    return-void
.end method

so we change it to:

Code:
.method public onCreate(Landroid/os/Bundle;)V
    .locals 3
    .parameter

    .prologue
    .line 31
    invoke-direct {p0, p1}, Ldelta/platforms/monodroid/downloader/DownloaderActivity;->n_onCreate(Landroid/os/Bundle;)V

    .line 32
    const/4 v0, 0x1
    const-string v1, "YOUR TEXT HERE"
    invoke-static {p0, v1, v0}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;
    move-result-object v0
    invoke-virtual {v0}, Landroid/widget/Toast;->show()V
    return-void
.end method

Because we use v1 and v0, so we make sure we have .locals at least 2, else it will give error. Normally i like to add the toast before its return, this will create a small toast message which stay about 2 sec when launching.


Another method is create pop out message which is nice looking and can have more descriptive words, but annoying:

Code:
new-instance v0, Landroid/app/AlertDialog$Builder;
    invoke-direct {v0, p0}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V
    const-string v1, "Hacked by J.Clow @ iOSCoderz"
    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;
    move-result-object v0
    const-string v1, "iOSCoderz.com"
    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setMessage(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;
    move-result-object v0
    const-string v1, "OK"
    const/4 v2, 0x0
    invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setPositiveButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
    move-result-object v0
    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->show()Landroid/app/AlertDialog;

Also put it at OnCreate of main launcher activity, also it need at least 3 locals.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.