Mahdi Azadbar
Mahdi Azadbar

Reputation: 1350

implement set as picture button in my app

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

Upvotes: 2

Views: 512

Answers (1)

Mahdi Azadbar
Mahdi Azadbar

Reputation: 1350

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

Upvotes: 1

Related Questions