-1

Following smali code gets a url from string and then we can share that link to other apps. But I want to send some permanent text instead of url or the text that's returned from string. For example, I want to share "hello, how are you" instead of the temporary text which is fetched from string. So what should I change in the following smali code to achieve this?

.line 512
const-string v2, "android.intent.action.SEND"

invoke-virtual {v1, v2}, Landroid/content/Intent;->setAction(Ljava/lang/String;)Landroid/content/Intent;

.line 513
const-string v2, "android.intent.extra.SUBJECT"

iget-object v3, p0, Lcom/myapp/c/b/q;->t:Lcom/myapp/a/b/c;

iget-object v3, v3, Lcom/myapp/a/b/c;->d:Ljava/lang/String;

invoke-virtual {v1, v2, v3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

.line 514
const-string v2, "android.intent.extra.TEXT"

new-instance v3, Ljava/lang/StringBuilder;

invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

iget-object v4, p0, Lcom/myapp/c/b/q;->t:Lcom/myapp/a/b/c;

iget-object v4, v4, Lcom/myapp/a/b/c;->d:Ljava/lang/String;

invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v3

const-string v4, "\n\n"

invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v3

invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v0

const-string v3, "\n\n"

invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v0

iget-object v3, v6, Lcom/myapp/a/a/n;->c:Ljava/lang/String;

invoke-static {v3}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

move-result-object v3

invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

move-result-object v0

invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v0

invoke-virtual {v1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

.line 515
const-string v0, "text/plain"

invoke-virtual {v1, v0}, Landroid/content/Intent;->setType(Ljava/lang/String;)Landroid/content/Intent;

.line 516
const v0, 0x7f020126

.line 517
invoke-virtual {p0, v0}, Lcom/myapp/c/b/q;->getString(I)Ljava/lang/String;

move-result-object v0

.line 518
invoke-static {v1, v0}, Landroid/content/Intent;->createChooser(Landroid/content/Intent;Ljava/lang/CharSequence;)Landroid/content/Intent;

move-result-object v0

invoke-virtual {p0, v0}, Lcom/myapp/c/b/q;->startActivity(Landroid/content/Intent;)V
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
.catch Ljava/lang/Error; {:try_start_0 .. :try_end_0} :catch_1

goto :goto_0

.line 519
:catch_0
move-exception v0

invoke-static {v0}, Lcom/myapp/d/e;->a(Ljava/lang/Exception;)V

goto :goto_0

.line 520
:catch_1
move-exception v0
user3548321
  • 523
  • 2
  • 8
  • 18
  • Your best bet is to code up something similar to what you want in java, and then compile+disassemble that and use it as the basis for what you want to do. – JesusFreke Apr 09 '16 at 17:32
  • Also, it's not very clear what you're asking :) – JesusFreke Apr 09 '16 at 17:33
  • There is a "share" button in an app. When we click it, it opens other apps where we can share a website url. The app fetches url from internet and when we click share, it'll load that link and we can share it. But what I'm asking is, instead of sharing a fetched link, I want to share some permanent text. Example, app fetches this link (www.example.com/abcd) and when we share, this link will be shared. Instead of that, I want to share some text always. Whenever i click share and it opens other apps to share(example whatsapp), I should be able to share this tex>> "this is app link" – user3548321 Apr 10 '16 at 01:02
  • I'm asking how to put some permanent value in this const-string v4, "\n\n" fields and disable fetching url from internet. Like this const-string v4, "This is app link \n\n Download it." – user3548321 Apr 10 '16 at 01:10
  • Yes, const-string is the instruction to load a string literal into a register. – JesusFreke Apr 10 '16 at 21:00
  • JesusFreke, I updated my question here and I think I was looking at the wrong smali file earlier. Can you please answer this? http://stackoverflow.com/questions/36588934/how-to-return-a-static-result-in-this-smali-code – user3548321 Apr 13 '16 at 05:02

1 Answers1

1

Some of the classes of your code are obfuscated, but with a bit of guessing we can find that the part that concatenate the html text is here:

iget-object v3, v6, Lcom/myapp/a/a/n;->c:Ljava/lang/String;

invoke-static {v3}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

move-result-object v3

invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

move-result-object v0

And if I'm not wrong, here in v0 there is the string that will be shared with the other app:

invoke-virtual {v1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
Luca D'Amico
  • 3,192
  • 2
  • 26
  • 38