I want something like this.
NOT the UI, just the data. (The metadata of an image)
In Chrome or some other browser when I browse I get a grid or a list of pictures and when I long press on any image it shows "Share image" option. So when I click on "Share image."
I want my application (REQUIREMENTS)
- to show up in the chooser dialog. (Working)
- Retrieve info about the image (title, URL, thumbnail) (Not working)
I have done the opposite many times (Sharing some link from my application to another Application like Gmail, WhatsApp, etc).
My question is if it is even possible at all? I have seen many application doing that( You can see in the image ) and have no idea how do they do that.
Here is what I have done so far in terms of code.
I have an activity registered with android.intent.action.SEND
intent filter in manifest. (Which makes my activity to appear in the list of Chooser dialog)
Here is the manifest
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
Here is the Activity code to retrieve the data.
public class MyActivity extends AppCompatActivity{
private TextView textView;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.phot_save_layout);
textView = (TextView)findViewById(R.id.count);
takeValueFunc();
}
public void takeValueFunc()
{
Intent shareIntent = getIntent();
if(shareIntent.getAction().equals(Intent.ACTION_SEND))
{
String text = shareIntent.getStringExtra(Intent.EXTRA_TEXT);
}
}
}
I have done some digging with different browsers, and I read different values for the same image.
I have found a similar question on StackOverflow How to get params from android.intent.action.SEND
But it does not answer my question. :(
Now I want my application to... Retrieve info about the image (title, url, thumbnail)
That is not possible in general.
You are welcome to peruse through the documented extras for ACTION_SEND
. You are welcome to come up with your own algorithm for deciding how to interpret those extras. However, there is no requirement that you get the information that you are seeking.
For example, EXTRA_STREAM
may hold a Uri
. That Uri
should have a content
scheme. That Uri
, plus a ContentResolver
, should give you the concrete MIME type (as the MIME type on the Intent
may be a wildcard). If that is an image, you can use your favorite image-loading library to load the image into your thumbnail-sized visual representation.
But that's it.
Maybe EXTRA_TEXT
and/or EXTRA_SUBJECT
will hold other information you might use, but there is no requirement that, say, the HTTPS URL of the image be in either of those. After all, there may not be an HTTPS URL of the image, as the image may not be on the Internet. Similarly, the sending app may not have a "title", let alone send it as part of ACTION_SEND
somehow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With