Tutorial How to add a popup toast message in game startup

Mika Cybertron

PMT Elite Modder
Original poster
Staff member
Modding-Team
Mar 24, 2017
898
63,723
1,213
24
Indonesia
[Requirements]
0. A working brain
1. A Computer
2. The apk file, obviously
3. dex/Apk decompiler with xml decoding support eg.(Apktool)
4. Text editor (Notepad++, Sublime Text, Atom, notepad)

[Info]
What exactly are we trying to do?
toast-png.png


surelock-toast-messages-png.png

*see image* Pretty much looks like that, but you may notice some moded games here show up with custom text like "diHacked oleh Aku sayang", "Hacked by Me" etc.

[Body]
1. Decompile apk with tools that mentioned above
2. Open AndroidManifest.xml, look for <action android:name="android.intent.action.MAIN"/>

Code:
<activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:launchMode="singleTop" android:name="net.circleous.domtweaks.StartActivity" android:screenOrientation="landscape">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>
</activity>
if you read that carefully and see on top of it(<action android:name="android.intent.action.MAIN"/>) -> android.name="net.circleous.domtweaks.StartActivity"
You have to find StartActivity.smali file at smali/net/circleous/domtweaks/
3. If you found the StartActivity.smali file, open it.
4. Search the word "onCreate" it'il be look like this.

Code:
.method protected onCreate(Landroid/os/Bundle;)V
.locals
5. Add this under .locals

Code:
const/4 v0, 0x1

const-string v1, "YOUR MESSAGE 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

#OTHER CODE THAT YOU MAY NOT TOUCH IT
6. If you notice in line 2

Code:
const-string v1, "YOUR MESSAGE"
Change "YOUR MESSAGE" to everything what you want.
Example:
Code:
const/4 v0, 0x1

const-string v1, "Platinmods.com"

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
7. Recompile, sign and install the apk

Credit:
HannCreator
iAndroHacker
 

DESLOKAT

18+ PMT Elite Modder
Staff member
FSK18
Modding-Team
Apr 20, 2017
10,415
1,238,924
1,213
36
Aincrad
A question. Sometimes i added this Code under locals and recompile, the Game forceclosed. I have 3 Games it Works and other Games it dosn't work. What's wrong? Its the correct smali and i copied the Code direct without a enter(empty Line).
 
  • Like
Reactions: nik2143

ZDooX

Rookie
Jan 15, 2019
4
0
13
35
UK
damn!! still can`t make this fk thing make it work, can`t find the line code and the exact directory where the toast message location..

any other alternative more simple for this custom toast message?
 

DaRealPanDa

Co-Administrator
Staff member
Supporting-Team
Global Moderator
Social Media
Mar 12, 2018
6,665
15,468
2,120
27
Skyrim
damn!! still can`t make this fk thing make it work, can`t find the line code and the exact directory where the toast message location..

any other alternative more simple for this custom toast message?
This is already the most easiest way to make a toast message buddy.
 
  • Like
Reactions: Braz-Mods

DaRealPanDa

Co-Administrator
Staff member
Supporting-Team
Global Moderator
Social Media
Mar 12, 2018
6,665
15,468
2,120
27
Skyrim
And when the file is encoded?
You need to decompile the apk buddy.
But it's not needed to do that, because APK Easy Tool shows your everytime the right Activity, just drag and drop the apk into APK Easy Tool
 
  • Love
Reactions: Braz-Mods

Braz-Mods

Approved Modder
Approved Modder
Oct 16, 2018
120
7,478
1,193
36
My world
You need to decompile the apk buddy.
But it's not needed to do that, because APK Easy Tool shows your everytime the right Activity, just drag and drop the apk into APK Easy Tool
There was no success because these 2 boxes were checked! For it to work it disables
Thanks again for the support :face46:
 

Attachments

  • Like
Reactions: Sevol and Djangø

Evilclown

Solid & Active Platinian
Jun 25, 2018
66
4,412
183
Usa
So what if it doesn't have android.name="XXX.XXX.XXXXXX.StartActivity" ?

<application android:allowBackup="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:icon="@mipmap/app_icon" android:label="@string/app_name" android:theme="@style/UnityThemeSelector">
<meta-data android:name="android.max_aspect" android:value="1.86"/>
<activity android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:hardwareAccelerated="false" android:label="@string/app_name" android:launchMode="singleTask" android:maxAspectRatio="1.86" android:name="com.unity3d.player.UnityPlayerActivity" android:resizeableActivity="false" android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

Already tried in the smali folder for android:name="com.unity3d.player.UnityPlayerActivity" and made the game crash
 

Opie1423

Platinian
Aug 30, 2019
10
27
13
Malaysia
doesnt have .local .. Just like this..

.method protected onCreate(Landroid/os/Bundle;)V
.registers 5
.param p1, "savedInstanceState" # Landroid/os/Bundle;
 

DaRealPanDa

Co-Administrator
Staff member
Supporting-Team
Global Moderator
Social Media
Mar 12, 2018
6,665
15,468
2,120
27
Skyrim
doesnt have .local .. Just like this..

.method protected onCreate(Landroid/os/Bundle;)V
.registers 5
.param p1, "savedInstanceState" # Landroid/os/Bundle;
post below the .registers 5
 

WCJongkok

Solid & Active Platinian
May 11, 2020
60
1,772
183
29
Heaven
is all game supported to use this toast code? i have 3 games modded and use this toast is work perfectly, but i'm modding new game and want to add toast, now it's always force close :pepe002: