Android Question How to make whatsapp call with intent

jahswant

Well-Known Member
Licensed User
Java:
String data = "content://com.android.contacts/data/" + dataId;
            String type = "vnd.android.cursor.item/vnd.com.whatsapp.profile";
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_VIEW);
            sendIntent.setDataAndType(Uri.parse(data), type);
            sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
POSSIBLE SOLUTION FOUND HERE :
 

syerif

Member
Licensed User
B4X:
Dim in As Intent
in.Initialize(in.ACTION_VIEW, "content://com.android.contacts/data/" & dataId)
in.SetType("vnd.android.cursor.item/vnd.com.whatsapp.profile")
in.SetPackage("com.whatsapp")
Try
 StartActivity(in)
Catch
 Log("whatsapp not installed")
End Try
Is dataid from content resolver or can use direct variable with phone number?
 

syerif

Member
Licensed User
this code
B4X:
Dim in As Intent
in.Initialize(in.ACTION_VIEW, "content://com.android.contacts/data/" & dataId)
in.SetType("vnd.android.cursor.item/vnd.com.whatsapp.profile")
in.SetPackage("com.whatsapp")
Try
StartActivity(in)
Catch
Log("whatsapp not installed")
End Try
this code do not effect to make a call ...

i also modify that code into this one and also not work

https://stackoverflow.com/questions/38655458/android-make-whatsapp-call

any suggestion?
this is my code

My code:
Dim in As Intent
    Dim tc As Technis
    Dim dataid As String=tc.GetContactIDbyPhone("62xxxxxx")
    Log(dataid)
    Dim name As String = tc.GetContactNamebyPhone("62xxxxxx")
    'Log(name)
    in.Initialize(in.ACTION_VIEW, "content://com.android.contacts/data/" & dataid)
    in.SetType("vnd.android.cursor.item/vnd.com.whatsapp.profile")
    in.SetPackage("com.whatsapp")
    Try
        StartActivity(in)
    Catch
        Log("whatsapp not installed")
    End Try
 

syerif

Member
Licensed User
Java:
String data = "content://com.android.contacts/data/" + dataId;
            String type = "vnd.android.cursor.item/vnd.com.whatsapp.profile";
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_VIEW);
            sendIntent.setDataAndType(Uri.parse(data), type);
            sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
POSSIBLE SOLUTION FOUND HERE :
This code work if i used inline java, i think the problem is mimetype, can i use contactutils to detect mimetype to get id from phone number?
 
Top