Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Update NativeShare.cs #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Plugins/NativeShare/NativeShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,23 @@ public static bool TargetExists( string androidPackageName, string androidClassN
if( androidClassName == null )
androidClassName = string.Empty;

return AJC.CallStatic<bool>( "TargetExists", Context, androidPackageName, androidClassName );
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
AndroidJavaObject launchIntent = null;
try
{
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", androidPackageName);
}
catch (System.Exception ex)
{
Debug.Log("exception" + ex.Message);
}
if (launchIntent == null)
return false;
return true;
#else
return true;
return false;
#endif
}

Expand Down Expand Up @@ -321,4 +335,4 @@ private byte[] GetTextureBytesFromCopy( Texture2D texture, bool isJpeg )
}
#endregion
}
#pragma warning restore 0414
#pragma warning restore 0414