I am making an app that you can share .mp3 on whatsapp directly with a button inside the app. Share button works properly on Android 6.0 and the versions below. But on Android 7.0 or 7.1.1, share doesn't work at all. Does anybody know why this activity is not doing anything on the new version?
Here is the share function I have
public void sendProccess(string filePath, AudioClip clip)
{
filePath = Application.persistentDataPath + "/" + clip.name + ".mp3";
//instantiate the class Intent
AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
//instantiate the class Uri
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + filePath);
//call putExtra with the uri object of the file
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
intentObject.Call<AndroidJavaObject>("setType", "audio/mp3");
//instantiate the class UnityPlayer
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
//instantiate the object currentActivity
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
//call the activity with our Intent
currentActivity.Call("startActivity", intentObject);
}