implement set as picture button in my app - android

I displayed images from webservice using json. Now how to provide user to make image as profile picture for whatsapp or contact photo etc., How to call that intent to open set picture as -> Set as -> showing multiple options -> Contact photo wallpaper, whatsapp profile photo etc.,?
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(Uri.parse(filename.getAbsolutePath()), "image/*");
intent.putExtra("jpg", "image/*");
startActivity(Intent.createChooser(intent, ("set as")));

use this code.
File externalFile=new File("filePath")
Uri sendUri = Uri.fromFile(externalFile)
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(sendUri, "image/jpg");
intent.putExtra("mimeType", "image/jpg");
startActivityForResult(Intent.createChooser(intent, "Set As"), 200);

Related

Set wallpaper without wallpaper manager, call default set as methods

i am trying to call default wallpaper set as method but its not working
i have tried so many code over stack but its not working so please any one have solution for it please reply
Uri uri = Uri.parse(url.toString());
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(uri, "image/jpg");
intent.putExtra("mimeType", "image/jpg");
startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
Can u try the below code:
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setDataAndType(uri, "image/jpeg");
intent.putExtra("mimeType", "image/jpeg");
this.startActivity(Intent.createChooser(intent, "Set as:"));

Open image for sharing

I have Android Xamarin application with imageview
OnClik I lunch intent to preview image
File file = new File(photoPath);
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(Uri.FromFile(file), "image/*");
intent.SetFlags(ActivityFlags.NoHistory);
StartActivity(intent);
from apps I choose 'Gallery'
when the image is opend there are no sharing options
when I open image from device 'Gallery' has sharing options
Image is saved to SD card before preview.
what am I doing wrong ?
solution that worked for me
Intent intent = new Intent();
intent.PutExtra(Intent.ActionView, photoPath);
intent.SetType("image/*");
StartActivity(Intent.CreateChooser(intent, "Select Picture"));
now I get my image opend in gallery and I can use sharing options too
Do it using Intent.ACTION_SEND and you'll get that sharing option.
Also try with Intent.ACTION_GET_CONTENT.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), 1);

Share image using intent chooser

How can I share images using intent chooser. I have tried
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/png");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse(url));
where url is from internet
I am able to share text using the above code the image doesnt get attached.
try doing this instead i think it will work
Uri uri = Uri.fromFile(new File(filename));
share.putExtra(Intent.EXTRA_STREAM, uri);

Android SDK: Let user choose picture from gallery or camera?

In my project I want to let the user pick a picture either from the gallery or take a new one from the camera. Do I need to create my own menu for the user to choose or is there something built into the SDK that does this already?
Use the below code to put chooser for gallery and Camera together. I really dont know if this will work with startActivityForResult. Give it a try
Intent galleryintent = new Intent(Intent.ACTION_GET_CONTENT, null);
galleryintent.setType("image/*");
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Intent chooser = new Intent(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT, galleryintent);
chooser.putExtra(Intent.EXTRA_TITLE, "title");
Intent[] intentArray = {cameraIntent};
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivity(chooser);

How to fire up the stock Gallery app with an image url that's in sd card

I have an image on the sd card. I need to fire up the stock Gallery app from my app to show the image. I get a NullPointerException from the stock Gallery app.
Here is my code.
Intent i = new Intent(Intent.ACTION_VIEW);
i.setType("image/png");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse(IMAGE_URL_ON_SD_CARD));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Can anyone help me understand what I am doing wrong?
Thanks a lot.
Try like this..
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/external/images/media/16")));
If above code do not work thn try like this
Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*"); startActivity(intent);

Categories

Resources