-2

I need to open all applications installed in my phone into my android application for sharing contents, can I find a simple method ?

Vishal Chhodwani
  • 2,567
  • 5
  • 27
  • 40

2 Answers2

2

I think you can try this if data is in text format

    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);

    sharingIntent.setType("text/plain");
    String shareBody = "Here is the share content body";

    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);


    startActivity(Intent.createChooser(sharingIntent, "Share via"));
Nazim ch
  • 834
  • 8
  • 20
1

Your question is un-clear. But I think I got your question.

You want to share some data?

you have to Use share Intent

Here is Example-

Share Text Data-

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));

Share Image

String fileName = "image-3116.jpg";//Name of an image
String externalStorageDirectory =     Environment.getExternalStorageDirectory().toString();
String myDir = externalStorageDirectory + "/saved_images/"; // the file will be in saved_images
Uri uri = Uri.parse("file:///" + myDir + fileName);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/html");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share Deal"));
Vishal Chhodwani
  • 2,567
  • 5
  • 27
  • 40
  • If the question is unclear, please flag as such, don't answer. I might read and understand it differently and give a completely different answer. – Adriaan Feb 21 '17 at 11:27
  • @Adriaan you are right but I understood what sree want. So I gave Answer, that is better to flag. – Vishal Chhodwani Feb 21 '17 at 11:30