vicky
vicky

Reputation: 41

how to change profile picture on whatsapp

I want to access the dp (profile picture) option of whatsapp using android code I have used that code

Code

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND);
            intent.putExtra(Intent.EXTRA_STREAM,uri);
            intent.setPackage("com.whatsapp");
            intent.setType("image/*");
            startActivity(intent);

but every time it open with share image option instead of change dp picture option in whatsapp i don't know where i am doing mistake I hope anyone here can help me. Thanks

guys i corrected question what actually i am asking

Upvotes: 0

Views: 3947

Answers (3)

Janardan Borada
Janardan Borada

Reputation: 11

   if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
    {
        uri=FileProvider.getUriForFile(getApplicationContext(),BuildConfig.APPLICATION_ID+".provider",new File(list.get(position)));
    }else{
        uri=Uri.parse(list.get(position));
    }
    Intent intent=new Intent(Intent.ACTION_ATTACH_DATA);
    intent.setDataAndType(uri,"image/*");
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.putExtra(Intent.EXTRA_STREAM,uri);
    startActivity(intent);

Upvotes: 0

Pankaj Lilan
Pankaj Lilan

Reputation: 4453

Finally after 1 day of exploring I came up with the Solution

Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(uri), "image/jpg");
intent.putExtra("mimeType", "image/jpg");
startActivityForResult(Intent.createChooser(intent, "Set image as"), 200);

With the help of this code snippet, you can set profile photo of Whatsapp as well as Contacts.

Upvotes: 3

iasoftsolutions
iasoftsolutions

Reputation: 251

You can open Whatsapp or share image and video but can't change profile picture from your own app.

Upvotes: 0

Related Questions