Android Question contact Whatsapp

andredamen

Active Member
Licensed User
Longtime User
When I try to contact Whatsapp whith:
Intent1.Initialize(Intent1.ACTION_VIEW, $"https://api.whatsapp.com/send?phone=${"+31"&Main.TelefoonNummer}&text=${AppTekst}"$)
I get whit some older telephones the following error:

android.content.ActivityNotFoundException: Unable to find explicit activity class {android/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?

It works well with all newer phones.

How can I solve this problem? Please help.
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
Apart from your whatsapp problem, this code will not work. Based on the country code +31 of the Netherlands, a phone number starts with either 06 or +316. So by putting +31 in front of it you get +3106 or +31316. In both cases, calling with such a telephone number will not work. So you will first have to test whether the telephone number starts with a + charter, if so then nothing needs to be changed, if not then you have to remove the 0 and put +31 in front.
Maybe you are lucky, and it will work after this adjustment.
 
Upvote 0

andredamen

Active Member
Licensed User
Longtime User
MicroDrie, As I said it works well on new phones. On phones that have Android 6 or older I get this error message. I have changed the telephonenumber into +316 and I still get this error. How do I declare this activity in the Androidmanifest as said in the error message?
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
I'm certainly no Android expert, but around version 6 the permissions were tightened up. Perhaps the following addition will help:
B4X:
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="19" />
)
GetSafeDirDefaultExternal doesn't require any permission on Android 4.4+ (API 19) and requires the WRITE_EXTERNAL_STORAGE on older versions. The code above adds the permission to older devices.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
In the answer from Erel.
As always Erel has the solution for every problem ?
 
Upvote 0
Top