简体   繁体   English

如何在whatsapp上更改个人资料图片

[英]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我想使用 android 代码访问 whatsapp 的 dp(个人资料图片)选项我使用了该代码

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.但是每次打开时都使用共享图像选项而不是在whatsapp中更改dp图片选项我不知道我在哪里做错了我希望这里的任何人都可以帮助我。 Thanks谢谢

guys i corrected question what actually i am asking伙计们,我纠正了我实际上在问什么

Finally after 1 day of exploring I came up with the Solution最后经过1天的探索,我想出了解决方案

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 .借助此代码段,您可以设置Whatsapp的个人资料照片以及联系人

您可以打开 Whatsapp 或分享图像和视频,但不能从您自己的应用程序更改个人资料图片。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何找回较旧的Whatsapp个人资料图片? - How to retrieve older Whatsapp profile picture? Flutter 如何在 Android 上获取 WhatsApp 个人资料图片 - Flutter How to get WhatsApp profile picture on Android 用户的whatsapp应用程序如何检测其联系人的个人资料图片中的变化? - How does user's whatsapp application detects change in profile picture of its contact? Whatsapp喜欢个人资料图片动画 - Whatsapp like profile picture animation 在线性布局内对齐线性布局,例如 whatsapp 更改个人资料图片 - Aligning linear layouts inside linear layout like whatsapp change profile picture 如何使用 Mesibo 更改个人资料图片? - How to change profile picture using Mesibo? Android打开图像onclick像Whatsapp Profile Picture - Android open Image onclick like Whatsapp Profile Picture 如何创建允许个人资料图片上传/更改的应用程序? - How To Create An App That Allows For Profile Picture Upload/Change? 如何创建一个允许个人资料图片永久上传/更改的应用 - How To Create An App That Allows For Profile Picture Upload/Change permanently 如何使用facebook android sdk更改facebook个人资料图片? - how to change the facebook profile picture using facebook android sdk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM