Android Question Share Text Intent Creation

jazzzzzzz

Active Member
Licensed User
Longtime User
How can I create this Intent to share text .
B4X:
Intent sendIntent =newIntent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,"This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
Details here.

http://developer.android.com/training/sharing/send.html
 

jazzzzzzz

Active Member
Licensed User
Longtime User
I wrote Inline java for the time being.

B4X:
#If JAVA
import android.content.Intent;
public void SendAction(){
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, "Please check out");
    sendIntent.setType("text/plain");
    startActivity(Intent.createChooser(sendIntent, "Share Via"));
    }
#End If
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

fredo

Well-Known Member
Licensed User
Longtime User
...possible to raise an event after the sharing is completed?

Yes, it is possible with a detour via a dispatcher in Activity_Resume.

I'm not sure if this is the most effective way to do it, but I used it in a lot of projects without problems.

Since the intent returns to Activity_Resume you can set flags before you start the intent...

30-09-_2016_10-36-33.jpg
... and dispatch them after the intent is finished

30-09-_2016_10-22-05.jpg

30-09-_2016_10-31-45.jpg

In the Select-case structure you can now react specifically to the action that was performed, e.g. Toastmessage(..Val1 & " sent") .



 
Upvote 0
Top