androidandroid-intentwhatsapp

Using intent to start WhatsApp with just an URL


I'm using intents to link to several social media apps in a native android app. This looks like the following:

Intent intent = new Intent(
                android.content.Intent.ACTION_VIEW,
                Uri.parse("https://whatsapp.com/channel/CHANNEL_ID"));
this.requireActivity().startActivity(intent);

This code works perfectly fine with Facebook, Instagram and TikTok. If the apps are installed it will open them, if not it will open a webbrowser.

But with WhatsApp nothing happens. My Fragment is paused and immideatly resumed and that's it. If I use the PackageManager and use "com.whatsapp" it works perfectly fine, but I would like to not do this because those links are dynamically loaded and I would like to not implement a "WhatsApp exception".

Do you have any idea why this might be happening?


Solution

  • I found the solution myself. The problem was that I had WhatsApp installed, but not configured (not registered a Phone Number yet). So the intent did start whatsapp, but the app somehow couldn't handle the call and it seemed like nothing was happening.