implement set as picture button in my app

531 views Asked by At

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")));
1

There are 1 answers

0
Mahdi Azadbar On BEST ANSWER

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);