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);
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?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
it comes from one CONTACT in your Device.Is dataid from content resolver or can use direct variable with phone number?
this code do not effect to make a call ...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
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
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?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 :
Android Intent to call Whatsapp from code
I am using this code to call WhatsApp directly from my Call Logs app. This works well, but only if the phone number includes a valid country code. For example calling WhatsApp with 919789006685 wo...stackoverflow.com
HelloUse Google to find out a possible Intent.
We can help you porting it to B4A.