概述
packed-switch是smali的switch语句中的一种,主要用来做整数的条件分支语句。
这个例子比较简单,根据输入的参数输出不同的字符串:
.class public Lcom/alipay/helloworld/MainActivity;
.super Landroid/app/Activity;
.source "MainActivity.java"
# direct methods
.method public constructor <init>()V
.locals 0
.prologue
.line 7
invoke-direct {p0}, Landroid/app/Activity;-><init>()V
return-void
.end method
# virtual methods
.method protected onCreate(Landroid/os/Bundle;)V
.locals 3
.parameter "savedInstanceState"
.prologue
.line 11
invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V
.line 12
const/high16 v2, 0x7f03
invoke-virtual {p0, v2}, Lcom/alipay/helloworld/MainActivity;->setContentView(I)V
const v0, 0x02
.local v0, msgIndex:I
invoke-virtual {p0, v0} , Lcom/alipay/helloworld/MainActivity;->getMsgString(I)Ljava/lang/String;
move-result-object v0
.local v0, msg:Ljava/lang/String;
invoke-virtual {p0, v0}, Lcom/alipay/helloworld/MainActivity;->showToastMessage(Ljava/lang/String;)V
return-void
.end method
.method public showToastMessage(Ljava/lang/String;)V
.locals 1
const/4 v0, 0x01
invoke-static {p0, p1, 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
.method public getMsgString(I)Ljava/lang/String;
.locals 1
const-string v0,
"Hello,switch"
packed-switch p1,
:pswitch_data_0
:goto_0
return-object v0
:pswitch_0
const-string v0, "Hello,switch 0"
goto :goto_0
:pswitch_1
const-string v0, "Hello,switch 1"
goto :goto_0
:pswitch_2
const-string v0, "Hello,switch 2"
goto :goto_0
:pswitch_3
const-string v0, "Hello,switch 3"
goto :goto_0
:pswitch_data_0
.packed-switch 0x0
:pswitch_0
#0x0
:pswitch_1
#0x1
:pswitch_2
#0x2
:pswitch_3
#0x3
.end packed-switch
.end method
</pre><pre name="code" class="plain">
最后
以上就是负责书本为你收集整理的smali入门之packed_switch的全部内容,希望文章能够帮你解决smali入门之packed_switch所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复