social share button with setPackage and setClassName

I’m trying to make a game with social share buttons for Facebook, Twitter, Instagram, etc separately. Because there are lots of social network apps, I’d like to use general approach which can be used for all apps universally rather than specific APIs. I use GalaxyS6 as a test phone and Android version is 7.0. Below is my code. When I use this, Facebook comes up correctly.

private void openSnsTest()
    bool fail = false;
    AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
    AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
    AndroidJavaObject launchIntent = null;

        launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", "com.facebook.katana");
    catch (System.Exception e)
        fail = true;

    if (fail)
        Debug.Log("app not found");
        ca.Call("startActivity", launchIntent);

And to open Twitter, I think I have to set the className because there are several apps for the same package name.

I changed this line:

launchIntent = packageManager.Call("getLaunchIntentForPackage", "com.facebook.katana");

into these lines:

launchIntent = packageManager.Call("getLaunchIntentForPackage", "");

launchIntent.Call("setClassName", "", "");

And, it’s not working anymore. How can I call Twitter directly?

There is a Github project that handles intents in general, and I’ve put together a detailed answer to cover also IOS, all here.