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.