Question

I've written a simple quotes Android app (Activity) that I am adding a share option to. When the share icon is pressed, the quote is sent as text to the "share handler" (external to my app) and a menu of listening apps-that-can-share-stuff is displayed: Email, Facebook, Google+, Evernote, and the like. So far, so good.

One of the share options offered is "Add a pin" which is pinterest.com coming to the party. However when selected, an error message (via Toast) is displayed saying "Please use a valid Web address".

While the shared text did originate in a WebView, the content itself is not a URL, not even HTML, it's just plain text. The WebView, decoupled from the share logic, should not factor into the equation either. The simplified code I am using to replicate this sharing mishap follows:

 public void share() {
    String textToShare = "In the beginning was the thing, and one thing led to another. ~ Tom Robbins";
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    share.putExtra(Intent.EXTRA_TEXT, textToShare);
    startActivity(Intent.createChooser(share, "Share this quote..."));
  }

The behavior suggests that pinterest.com is only interested in sharing links (perhaps downloading entire web pages for all I know). Now, since I'm only sharing locally generated text, my question I guess is:

Is there a way (in my code) of excluding an app (like pinterest) that expects a "valid Web address" from getting notified when plain text is being shared.

My grasp of the Android share logic is minimal (I'm an Android dev newbie), still I'm hoping there may be some code modification (flag?) that would exclude the non-functioning "Add pin" from appearing in the external-to-app share menu. Hope all that makes sense.

Was it helpful?

Solution

@HarryHB i have found the solution of this

    String image_path="/mnt/sdcard/Pictures/20140419_205144.jpg";
    File file = new File(image_path);
    Uri uri = Uri.fromFile(file);
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    startActivity(intent);

But still unable to set the title and description even though i used this.

    intent.putExtra(Intent.EXTRA_TITLE, "Title");
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra("com.pinterest.EXTRA_DESCRIPTION", "your description");

Hope this will help u.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top