How to implement native gallery functions in my application - android

i have Samsung Galaxy S. In the phone's gallery there is a share button. When you click the button, a menu contains share sites show up. You can pick one ot them and upload the picture. The best part of the menu; İf you download an application(for example facebook) into your phone, it appers in the menu. İ want to you use that function in my app. I will use camera, take picture and display on the imageview. And then i want to make a button like this one and share the photo. I am asking that because i download a gallery application which is not the native gallery of the phone, It also has the same button. Is there anyway that i can use it directly in my application. I dont want to use it after calling the gallery.

try this code
intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "try this application ");
intent.putExtra(Intent.EXTRA_TEXT, "https://market.android.com/details?id=com.music.player");
startActivity(Intent.createChooser(intent, "Share with"));
for more information check this link

This code will help you to redirect to native gallery in your device.
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");

Related

Android - how to open image in gallery with delete option

I use following code to open an image in the gallery:
public void onItemClicked(PictureItem item){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imageUri = FileProvider.getUriForFile(getApplicationContext(), "myapp.fileprovider", new File(item.uri.getPath()));
intent.setDataAndType(imageUri, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
This shows my photo in the gallery, but in a 'read-only' mode. I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Which action do I have to use for that? I do not want to use pick, just normal view with the option to delete. I tried ACTION_EDIT but it's not supported (and not quite the right choice neither ...).
I use following code to open an image in the gallery
First, there are hundreds, if not thousands, of "gallery" apps available for Android.
Second, your code simply asks to view an image (with a broken Intent due to your wildcard MIME type). There is no requirement for the app that responds to be a "gallery" app.
I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Then implement that yourself, in your own app, and get rid of the ACTION_VIEW Intent.
Which action do I have to use for that?
There is no Intent action that says "please display this image, but only if you are a gallery app, and, oh, by the way, you must offer a delete option", which appears to be what you want.

while sharing image via share intent hangout shows old image inside image preview screen in android

while sharing image via android share intent hangout shows old image inside image preview screen which appears before sending image,but whatsapp and facebook shows cuurently selected image itself,
even it shows wrong image in preview ater clicking send, in chat correct image will only be displayed.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(Intent.createChooser(intent, "Share news via.."));
can any one help with this issue
I found reason behind this issue, i was giving same name everytime to store and share the image, by defalut hangout image send preview screen will display old image , if image name is same. so changing image name everytime will fix the issue.

Share an image taken from camera to image view

Hello I'm new to android studio I have built an app when you take a photo from the camera app see it in an ImageView and share it
I have made a share button:
case R.id.shrbtn:
startshare();
break;
the share button go to this method to start sharing the photo
I have added internet permission and the button don't do anything:
private void startshare() {
Bitmap bmp=viewToBitmap(Image,Image.getWidth(),Image.getHeight());
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri phototUri = Uri.parse(String.valueOf(Bitmap.createBitmap(bmp)));
shareIntent.setData(phototUri);
shareIntent.putExtra(shareIntent.EXTRA_STREAM,phototUri);
startActivity(Intent.createChooser(shareIntent, "Share Via"));
}
can anyone tell me what is missing?
Send it by an intent and get it from startActivityForResult() method.
This tutorial explains it well
This sounds to me like an issue regarding the button callback itself. Have you make sure that the method have been called? Maybe you should set breakpoints to identify the issue?
Maybe you should take a look here (as your share intent looks wrong): https://stackoverflow.com/a/7662164/6268503

how to make clicking on the item in "share" form with android espresso test

Trying to test the share function of the app, which is in the app it calls createChooser() to open the "sharing" chooser form.
startActivity(Intent.createChooser(sharingIntent, "Share something"));
Question is after the "sharing" chooser form is up how to simulate the clicking on some listed apps item, lets say there is app has description "AppName". Tried following it does not work, the chooser form stays there until the test timeout.
tried:
onView(withContentDescription("AppName"))
.perform(click());
and:
onView(withText("AppName"))
.perform(click());
Below is the example to share something in whatsapp:
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
waIntent.setPackage("com.whatsapp");//package name of whatsapp
waIntent.putExtra(Intent.EXTRA_TEXT, "Share Something");//text to share
startActivity(Intent.createChooser(waIntent,"Share via..."));
I hope this might help you.

Share Android app on Facebook with an image icon

I put a button to share my Android app on Facebook, so I wrote the following code
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
// add the app link
intent.putExtra(Intent.EXTRA_TEXT, "http://play.google.com/store/apps/details? id=com.phonelight.realparrot");
startActivity(Intent.createChooser(intent, "Share with Facebook"));
After sharing, I opened my Facebook account and saw the following:
As you can see, It should be an image in the right square. I am wondering how can I put that image, I am thinking to put my icon app
Like if you share a youtube link, the image will be the first shot of the movie.
Change intent.setType("text/plain");
to intent.setType("image/*");
then add intent.putExtra(Intent.EXTRA_STREAM, myImageContentUri);

Categories

Resources