How Can I Set My Selected Image From Gallery To My Application In Imageview Via Share Option.
I am building an application in which I can share my photo from gallery to my application, just the same concept as of 'PINTEREST'. But it undergoes through Login gateway and if a
Solution 1:
I got my answer :) This can be done by using Intent like this :
Intent intent = getIntent();
// Get the action of the intentString action = intent.getAction();
// Get the type of intent (Text or Image)Stringtype = intent.getType();
// When Intent's action is 'ACTION+SEND' and Tyoe is not nullif (Intent.ACTION_SEND.equals(action) && type != null) {
if (type.startsWith("image/")) { // When type is 'image/*'handleSendImage(intent); // Handle single image being sent
}
}
privatevoidhandleSendImage(Intent intent) {
// Get the image URI from intentUri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
// When image URI is not nullif (imageUri != null) {
// Update UI to reflect image being shared
view_news.setImageURI(imageUri);
news.setVisibility(View.GONE);
} else{
Toast.makeText(this, "Error occured, URI is invalid", Toast.LENGTH_LONG).show();
}
}
This solved my problem of getting image from gallery and displaying it in imageview like in 'pInterest' application. Thanks :)
Post a Comment for "How Can I Set My Selected Image From Gallery To My Application In Imageview Via Share Option."