1

Currently I have a Button which will share an URL with a friend by using WhatsApp.

However, is there a way to return them back to my app after the message has been sent?

Here is my code so far.

whatsapp_item.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent whatsapp_intent = new Intent();
        whatsapp_intent.setAction(Intent.ACTION_SEND);
        whatsapp_intent.putExtra(Intent.EXTRA_TEXT, "Hey, i think you will like this. Check it out " + url);
        whatsapp_intent.setType("text/plain");
        whatsapp_intent.setPackage("com.whatsapp");
        startActivity(whatsapp_intent);
    }
});
Bono
  • 4,757
  • 6
  • 48
  • 77
  • 2
    what do you mean by `return them` ? and did you try `startActivityForResult()` ? – Yazan Feb 16 '15 at 10:10
  • 1
    no. you cant. after you send intent to other app, then is up to them. you cannot change other app code – Randyka Yudhistira Feb 16 '15 at 10:15
  • I think startActivityForResult() will not work. I´ve seen it by sending Audio, Video or Images vial What´s app from other apps, it doesn´t return to this app automatically... – Opiatefuchs Feb 16 '15 at 10:19
  • 1
    return as in going back to my app. I just tried using this feature in pinterest and it stays in whatsapp. Maybe its not possible –  Feb 16 '15 at 10:30
  • 1
    There is no way to return back automatically but you can start particular activity after certain time – Apurva Feb 16 '15 at 11:11
  • @Apurva do you mean after so many seconds of starting the intent? –  Feb 16 '15 at 11:38
  • Invoke a thread when you send an intent to start whatsapp and set some time to make a thread wait before invoking. – Apurva Feb 16 '15 at 11:43
  • Ok thanks. I'll give it a go but will probably leave it out of the app. Ill see how it performs –  Feb 16 '15 at 11:47

0 Answers0