[英]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.