Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,728,048 Members 46,598 Now Online
XDA Developers Android and Mobile Development Forum

How to create Custom Button OnClick (CM7.2)

Tip us?
Junior Member - OP
Thanks Meter 0
Posts: 3
Join Date: Aug 2013
Location: Puebla, Angelopolis
Smile How to create Custom Button OnClick (CM7.2)


I share my Mod

Decompile your SystemUI (with Apk Multi Tool or other tool)

Go to smali/android/systemui/statusbar  and open StatusBarService.Smali
and find

.method public settingsButton(Landroid/view/View;)V
    .locals 3
    .parameter "v"

    .line 1717
    invoke-virtual {p1}, Landroid/view/View;->getContext()Landroid/content/Context;

    move-result-object v0

    new-instance v1, Landroid/content/Intent;

    const-string v2, "android.settings.SETTINGS"

    invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    const/high16 v2, 0x1000

    invoke-virtual {v1, v2}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    invoke-virtual {p0}, Lcom/android/systemui/statusbar/StatusBarService;->animateCollapse()V

    .line 1720
.end method
below just copy and paste the code

.method public zorekhcustombutton(Landroid/view/View;)V
    .locals 11
    .parameter "v"

    new-instance v0, Landroid/content/Intent;

    invoke-direct {v0}, Landroid/content/Intent;-><init>()V

    invoke-virtual {p1}, Landroid/view/View;->getTag()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/String;

    const-string v3, ","

    invoke-virtual {v5, v3}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v6

    const/4 v4, 0x0

    aget-object v4, v6, v4

    const/4 v7, 0x1

    aget-object v7, v6, v7

    invoke-virtual {v0, v4, v7}, Landroid/content/Intent;->setClassName(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const/high16 v2, 0x1000

    invoke-virtual {v0, v2}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    move-result-object v0

    invoke-virtual {p0, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    const-string v1, "statusbar"

    invoke-virtual {p0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/StatusBarManager;

    invoke-virtual {v0}, Landroid/app/StatusBarManager;->collapse()V


    move-exception v0

    .local v0, e:Ljava/lang/Exception;
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    const-string v10, "Error:\n"

    invoke-virtual {v10, v5}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    const/16 v9, 0x7d0

    invoke-static {p0, v5, v9}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v8

    invoke-virtual {v8}, Landroid/widget/Toast;->show()V

    goto :goto_0
.end method
use now

android:tag="Package,Activity" to insert the activity to open 

Sorry for mi bad english
CosmicDan's Avatar
Senior Member
Thanks Meter 3802
Posts: 3,970
Join Date: Jun 2009
Location: Central Coast

Nice work mate! I was just googling for quick reference to start activity in smali, and this is best result so far. Some suggestions though:

Add to title or subtitle something like "Start Activity from XML tag in Smali"

And maybe some comments in your code like this:

# v0 is an instance of Intent
# v4 is the packageName, e.g. ""
# v7 is the className, e.g. ".DateTimeSettingsSetupWizard"
invoke-virtual {v0, v4, v7}, Landroid/content/Intent;->setClassName(Ljava/lang/String;Ljava/lang/StringLandroid/content/Intent;


XtreamerMobile Developer

My GitHub | My Apps on AppBrain

Goodbye Xperia 2011 scene - on to greater things

Current Community Projects:
Turbo Tools - Suspended

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Pale Moon Browser Ported to Android

Having a wide choice of third party applications is one of the most beautiful things that Android has to … more

Partial Android Wear Source Uploaded to AOSP

2014 is certainly shaping up to be theyear of the wearables. And thanks to its innovative … more

Street Panorama Combines Google Maps and Street View into One App

Google Maps is a must have application forevery amateur world explorer. … more

XDA Behind the Scenes, Part 3

This is the last part of a series of articles that reveals some of the processes, technology, and systems that … more