Android Share Via Dialog

I saw the "share via" dialogs found in applications like TFLN (last night's texts). Looks like this: general dialogue http://garr.me/wp-content/uploads/2009/12/sharevia.jpg

I want to share the text. Can someone point me in the right direction? Is this done with intent?

+50
android
Aug 24 2018-10-10T00:
source share
3 answers

This is truly done through intentions.

For image sharing, for example, in the example, it would be something like this:

Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/jpeg"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/DCIM/Camera/myPic.jpg")); startActivity(Intent.createChooser(share, "Share Image")); 

For text, you should use something like:

 Intent share = new Intent(Intent.ACTION_SEND); share.setType("text/plain"); share.putExtra(Intent.EXTRA_TEXT, "I'm being sent!!"); startActivity(Intent.createChooser(share, "Share Text")); 
+105
Aug 24 '10 at 2:10
source share

I am having problems with the accepted answer. What worked for me was to create the file from the path and then parse the file URI, for example:

 Uri.fromFile(new File(filePath)); 

instead

 Uri.parse(filePath) 

Just in case, someone has the same problem.

+6
Nov 24 '12 at 4:50
source share

Yes. You need to provide an Activity with an intent filter that can process objects like MIME image / jpeg (say if you want to support sharing of JPEG images) and actions supposedly ACTION_SEND.

Many of the built-in Android applications are open-source, you can check the manifest file of the Messaging application to see which intent filters it uses.

+4
Aug 24 '10 at 1:54
source share



All Articles