WhatsApp Profile picture using intent

739 views
Skip to first unread message

Durga Prasad

unread,
May 25, 2016, 10:50:42 AM5/25/16
to DroidScript
Hi,

I am trying to set WhatsApp Profile picture from my app with predefined image.

I can able to open the whatsapp profile picture screen. But I am not sure how to continue further to set the new image and save the changes.

This is the code so far I have.

//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" );

//Create image.
img = app.CreateImage( "/Sys/Img/Hello.png", 0.1 );
lay.AddChild( img );


//Create a 'Send Image' button
btnImg = app.CreateButton( "Send Image to whatsapp", 0.8 );
btnImg.SetMargins( 0, 0.05, 0, 0 );
btnImg.SetOnTouch( btnImg_OnTouch );
lay.AddChild( btnImg );


//Add layout to app.
app.AddLayout( lay );
}

//Send a file to another App (user's choice).

//Send an image to Google Drive.
function btnImg_OnTouch()
{
var file = "/Sys/Img/Hello.png";
img.Save( file );

var packageName = "com.whatsapp";
var className = "com.whatsapp.SetAsProfilePhoto";
var action = "android.intent.action.ATTACH";
var category = "android.intent.category.DEFAULT"
var uri = null;
var type = "multipart/*";
var extras = [
{name:"android.intent.extra.STREAM", type:"file", value: "/Sys/Img/Hello.png"}
];

extras = JSON.stringify( extras );
app.SendIntent(packageName, className, action, category, uri, type, extras);
}

Any help is appreciated.

Gerard Hernandez

unread,
May 25, 2016, 11:27:09 AM5/25/16
to DroidScript
Hi, whatsapp its a real nasty and unfriendly app when it comes to 3rd party interaction.

You will be able to do pretty much nothing with whatsapp, the most you wil be able to do is, open specific activities, open a specific contact chat or open the contact selector to choose from and prepopulate the message box, but you wont be able to send the message. Once DS get the capability to use actionable notifications, we may be able TO ONLY ANSWER INCOMMING MESSAGE, NOT CREATE NEW ONES.

You can get the image from a contact querying the contact provider. Once that is released to production, currently is only for alpha/beta testers. 

Dutch Developement Team

unread,
May 25, 2016, 11:36:02 AM5/25/16
to DroidScript
No, not only that. The "com.whatsapp.SetAsProfilePhoto" doesn't work with images, the function is made to select an image.... Not to receive one from a 3rd party application.

Durga Prasad

unread,
May 26, 2016, 4:56:43 AM5/26/16
to DroidScript
Okay thanks for the reply
Reply all
Reply to author
Forward
0 new messages