【移花接木】添加启动提示框类型(2)
效果:点击取消以后,无任何操作。
点击前往以后,会调用浏览器打开指定网址。
在启动页oncreate中添加:
invoke-virtual {p0, v0}, L当前页面地址;->setContentView(I)V
#v0是当前页面在public中的数值,p0无所谓,L路径要与当前java路径保持一致
.line 16
invoke-virtual {p0}, L当前页面地址;->Dialog2()V
#p0不管,L路径要与当前java路径保持一致
在当前页面下添加虚函数(# virtual methods):
.method public Dialog2()V
.locals 3
.prologue
.line 22
new-instance v0, Landroid/app/AlertDialog$Builder;
#v0=(UninitRef,Landroid/app/AlertDialog$Builder;);
invoke-direct {v0, p0}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V
.line 23
.local v0, "builder":Landroid/app/AlertDialog$Builder;
#v0=(Reference,Landroid/app/AlertDialog$Builder;);
const/4 v1, 0x0
#v1=(Null);
invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setIcon(Landroid/graphics/drawable/Drawable;)Landroid/app/AlertDialog$Builder;
.line 24
const-string v1, "\u6e29\u99a8\u63d0\u793a"
#v1=(Reference,Ljava/lang/String;);
invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;
.line 25
const-string v1, "\u65e0\u63d0\u793a"
invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setMessage(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;
.line 26
const-string v1, "\u524d\u5f80"
new-instance v2, L当前页面地址$跳转;
#v2=(UninitRef,L当前页面地址$跳转;);
invoke-direct {v2, p0}, L当前页面地址$跳转;-><init>(L当前页面地址;)V
#v2=(Reference,L当前页面地址$跳转;);
invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setPositiveButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
.line 39
const-string v1, "\u53d6\u6d88"
new-instance v2, L当前页面地址$取消;
#v2=(UninitRef,L当前页面地址$取消;);
invoke-direct {v2, p0}, L当前页面地址$取消;-><init>(L当前页面地址;)V
#v2=(Reference,L当前页面地址$取消;);
invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setNegativeButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
.line 47
invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;
move-result-object v1
invoke-virtual {v1}, Landroid/app/AlertDialog;->show()V
.line 48
return-void
.end method
在启动页目录插入两个新文件:
MainActivity$1.smali
MainActivity$2.smali
#如果出现重名,则递进
MainActivity$1.smali文件内容:
.class L当前页面地址$跳转;
.super Ljava/lang/Object;
.source "MainActivity.java"
# interfaces
.implements Landroid/content/DialogInterface$OnClickListener;
# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
value = L当前页面地址;->Dialog2()V
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x0
name = null
.end annotation
# instance fields
.field final synthetic this$0:L当前页面地址;
# direct methods
.method constructor <init>(L当前页面地址;)V
.locals 0
.prologue
.line 1
iput-object p1, p0, L当前页面地址$跳转;->this$0:L当前页面地址;
.line 26
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
#p0=(Reference,L当前页面地址$跳转;);
return-void
.end method
# virtual methods
.method public onClick(Landroid/content/DialogInterface;I)V
.locals 3
.param p1, "dialog" # Landroid/content/DialogInterface;
.param p2, "which" # I
.prologue
.line 31
new-instance v1, Landroid/content/Intent;
#v1=(UninitRef,Landroid/content/Intent;);
invoke-direct {v1}, Landroid/content/Intent;-><init>()V
.line 32
.local v1, "intent":Landroid/content/Intent;
#v1=(Reference,Landroid/content/Intent;);
const-string v2, "android.intent.action.VIEW"
#v2=(Reference,Ljava/lang/String;);
invoke-virtual {v1, v2}, Landroid/content/Intent;->setAction(Ljava/lang/String;)Landroid/content/Intent;
.line 33
const-string v2, "需要跳转到的网页,U码"
invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;
move-result-object v0
.line 34
.local v0, "content_url":Landroid/net/Uri;
#v0=(Reference,Landroid/net/Uri;);
invoke-virtual {v1, v0}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;
.line 35
iget-object v2, p0, L当前页面地址$跳转;->this$0:L当前页面地址;
invoke-virtual {v2, v1}, L当前页面地址;->startActivity(Landroid/content/Intent;)V
.line 36
return-void
.end method
MainActivity$2.smali文件内容:
.class L当前页面地址$取消;
.super Ljava/lang/Object;
.source "MainActivity.java"
# interfaces
.implements Landroid/content/DialogInterface$OnClickListener;
# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
value = L当前页面地址;->Dialog2()V
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x0
name = null
.end annotation
# instance fields
.field final synthetic this$0:L当前页面地址;
# direct methods
.method constructor <init>(L当前页面地址;)V
.locals 0
.prologue
.line 1
iput-object p1, p0, L当前页面地址$取消;->this$0:L当前页面地址;
.line 39
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
#p0=(Reference,L当前页面地址$取消;);
return-void
.end method
# virtual methods
.method public onClick(Landroid/content/DialogInterface;I)V
.locals 0
.param p1, "dialog" # Landroid/content/DialogInterface;
.param p2, "which" # I
.prologue
.line 44
invoke-interface {p1}, Landroid/content/DialogInterface;->dismiss()V
.line 45
return-void
.end method
实例下载方便比对:
你的回复是作者们的动力0.0
转载请说明地址:pd521.com
好贴 好贴 支持........ 屌屌屌!学习啦学习啦~ 来学习了{:4_87:} 谢谢分享,很有用的技巧! 支持一个!!!! 感谢分享!!!!! 好用,又装逼价值 就喜欢移植 diy{:4_87:}感谢楼主 好贴 好贴 支持........
页:
[1]