Search Unity

Native Share for Android & iOS [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, Mar 1, 2018.

Thread Status:
Not open for further replies.
  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I believe all those social platforms store the shared content on their own databases, so you're fetching these data from their servers, not from your local storage.
     
  2. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    51
    hello, im triying to share only on email app (ios).
    following the recomendation of this thread I excluded these:
    Code (CSharp):
    1. activity.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypeAirDrop, UIActivityTypeMessage, UIActivityTypeOpenInIBooks];
    but I cant find how to exclude whatsapp and notes app, its possible?.

    EDIT:
    reading this:
    https://stackoverflow.com/questions/33005258/ios-disabling-whatsapp-in-uiactivityviewcontroller

    something like:
    Code (CSharp):
    1. UIActivityType(rawValue: "net.whatsapp.WhatsApp.ShareExtension")
    can work?, but I cant find the correct syntax, it give me errors.
     
    Last edited: Jun 17, 2022
    yasirkula likes this.
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @elfasito Yes it could work. You can add it to the list like this:
     ..., UIActivityTypeOpenInIBooks, @"net.whatsapp.WhatsApp.ShareExtension"
    . But in the future, when a new social app is released, that app might be included in the list, so this solution is unfortunately not future-proof.
     
    elfasito likes this.
  4. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    51
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    That approach won't work in this case because it requires the target app (WhatsApp) to be developed by the same developer (you). I've now also seen some messages claiming that my suggested method doesn't work with 3rd party apps, sadly :/
     
    elfasito likes this.
  6. elvis-satta

    elvis-satta

    Joined:
    Nov 13, 2013
    Posts:
    19
    Hi @yasirkula, can i use this on the Oculus quest 2 ?
     
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @elvis-satta Hi! Some native functionalities work in VR (like permission asking) but I don't know if native sharing works in VR, so you'll need to give it a try.
     
    elvis-satta likes this.
  8. unity_WwOrUPBxBLbyDA

    unity_WwOrUPBxBLbyDA

    Joined:
    Apr 7, 2021
    Posts:
    4
    Hi, i imported NativeShare.unity package from your Github page, but it does not find NativeShare class. Unity 2021.2.0f1.
     
    Last edited: Jul 21, 2022
  9. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  10. unity_WwOrUPBxBLbyDA

    unity_WwOrUPBxBLbyDA

    Joined:
    Apr 7, 2021
    Posts:
    4
    Thanks! It worked, my beginner mistakes :D
     
    yasirkula likes this.
  11. chankeiro

    chankeiro

    Joined:
    Oct 25, 2021
    Posts:
    11
    Hi @yasirkula, thank you very much for this great asset.

    I am experiencing an issue with an Android 11-Xiaomi device that I hope you can help me to solve. My use case is a bit special since my app's main activity is native Android, and from that activity I am launching an Unity activity and, using your asset, I am sharing a video file from this Unity activity. Native Share worked right out the box in an Android 10 and Android 12, but I am receiving the following error when calling Share() in this Android 11 device:

    Code (CSharp):
    1. 2022-07-23 08:38:00.006 15416-15416/com.bercetech.fleepas E/AndroidRuntime: FATAL EXCEPTION: main
    2.     Process: com.bercetech.fleepas, PID: 15416
    3.     java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
    4.         at com.yasirkula.unity.NativeShareContentProvider.parsePathStrategy(NativeShareContentProvider.java:257)
    5.         at com.yasirkula.unity.NativeShareContentProvider.getPathStrategy(NativeShareContentProvider.java:233)
    6.         at com.yasirkula.unity.NativeShareContentProvider.getUriForFile(NativeShareContentProvider.java:88)
    7.         at com.yasirkula.unity.NativeShare.CreateIntentFromBundle(NativeShare.java:175)
    8.         at com.yasirkula.unity.NativeShareCustomShareDialog.onCreateDialog(NativeShareCustomShareDialog.java:82)
    9.         at android.app.DialogFragment.onGetLayoutInflater(DialogFragment.java:417)
    10.         at android.app.Fragment.performGetLayoutInflater(Fragment.java:1322)
    11.         at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1303)
    12.         at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2436)
    13.         at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2215)
    14.         at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2171)
    15.         at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2072)
    16.         at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3062)
    17.         at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:3014)
    18.         at android.app.FragmentController.dispatchStart(FragmentController.java:195)
    19.         at android.app.Activity.performStart(Activity.java:8152)
    20.         at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3527)
    21.         at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    22.         at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    23.         at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    24.         at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    25.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2108)
    26.         at android.os.Handler.dispatchMessage(Handler.java:106)
    27.         at android.os.Looper.loop(Looper.java:236)
    28.         at android.app.ActivityThread.main(ActivityThread.java:7876)
    29.         at java.lang.reflect.Method.invoke(Native Method)
    30.         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
    31.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
    32.  
    It looks like this line from parsePathStrategy is throwing a null info:
    Code (CSharp):
    1. ProviderInfo info = context.getPackageManager().resolveContentProvider(authority, 128);
    But no idea about why, because both context and authority shouldn't be null, and why only on this device. I've seen that shouldUseCustomShareDialog is true for being Android 11 - Xiaomi, but I don't know if that is related to this problem.

    I am testing it with SnapChat. I've added <package android:name="com.snapchat.android" /> to the manifest, but that didn't help either. I can provide you with the mergedmanifest in case you need it.

    I hope you can help me with this issue. Thank you very much in advance
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @unity_50B983B49CCDDD3CCE66 Yeah, could you share the merged AndroidManifest (via private message, if you want)? Could you also send me your Unity project's Bundle Identifier value?
     
  13. ArvinYou

    ArvinYou

    Joined:
    Jan 21, 2021
    Posts:
    2
    Hello, thank you for the great plugin. We got it working nicely on iOS and Android devices. However, there is a small problem with iOS devices. We want our users to be able to share images on Facebook through the native share, but once the Facebook post editing page shows up, it won't close. Both clicking on the discard button or post button won't close it. And there is no way to return to our app unless force close and restart it. Only sharing to Facebook has this problem, others work just fine. Do you by any chance know what is going on? Thank you so much.
     
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @ArvinYou I wonder if this happens when sharing content from other "Made with Unity" apps to Facebook, as well. Sometimes these issues are caused by the target social platform apps themselves and are fixed when they discover such issues and fix their apps. You may test another free sharing solution, NatShare, to see if this issue is specific to NativeShare.
     
    makaka-org likes this.
  15. ArvinYou

    ArvinYou

    Joined:
    Jan 21, 2021
    Posts:
    2
    Yes, you are right. I tested on other apps and they appear to have the same issue when sharing to Facebook. Thanks a lot.
     
    yasirkula likes this.
  16. Ram-Apprlabs

    Ram-Apprlabs

    Joined:
    Apr 19, 2022
    Posts:
    10
    i'm using your plugin for file explorer access in unity for andorid its works but if i click the upload button, my access shows like this pic. would you help me what problem is? i also grant the permission for storage access
    WhatsApp Image 2022-09-12 at 9.54.00 PM.jpeg
     
  17. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @Ram-Apprlabs Hi, on which Android version is this happening and what is the file's extension?
     
  18. Ram-Apprlabs

    Ram-Apprlabs

    Joined:
    Apr 19, 2022
    Posts:
    10
    anroid version 12 oneplus 9r model and i tried android 11 also the popup wil show in no apps can perform this action
     
    Last edited: Sep 13, 2022
  19. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    While calling AddFile, please try passing "application/octet-stream" as mime parameter. If that works, please let me know of the file's original extension.
     
  20. Ram-Apprlabs

    Ram-Apprlabs

    Joined:
    Apr 19, 2022
    Posts:
    10
    Hello @yasirkula, I'm a Learner now so currently i know the basics only and i follwed you in LinkedIn. My name is https://www.linkedin.com/in/jai-sriram/ would you help for futher more developments. and im using this code for access file manager load file is not working but i can write the file in file manager where i made the mistake
    im using file extension is System.IO;



    public class FilePickerAccess : MonoBehaviour
    {
    public string FinalPath;
    public RawImage rawImage;
    public TMP_Text _text;
    public void LoadFile()

    {

    string FileType = NativeFilePicker.ConvertExtensionToFileType("*");
    NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    {
    if (path == null)
    {
    Debug.Log("Operation Cancelled");
    _text.text = "Operation Cancelled";
    }
    else
    {
    FinalPath = path;
    Debug.Log("Picked File" + FinalPath);
    _text.text = "Picked File" + FinalPath;
    StartCoroutine(LoadTexture());
    }
    }, new string[] { FileType });
    }
    public void SaveFile()
    {
    string filePath = Path.Combine(Application.temporaryCachePath, "test.txt");
    File.WriteAllText(filePath, "Hello World");
    NativeFilePicker.Permission permission = NativeFilePicker.ExportFile(filePath, (success) => Debug.Log("File Exporrted: " + success));
    }
    IEnumerator LoadTexture()
    {
    UnityWebRequest request = UnityWebRequestTexture.GetTexture("file://" + FinalPath);
    while (!request.isDone)
    yield return request.SendWebRequest();
    if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
    {
    Debug.Log(request.error);
    _text.text = request.error;


    }
    else
    {
    rawImage.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
    _text.text = request.downloadHandler.ToString();

    // setting the loaded image to our object
    }



    }
    }
     
    Last edited: Sep 13, 2022
  21. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  22. Ram-Apprlabs

    Ram-Apprlabs

    Joined:
    Apr 19, 2022
    Posts:
    10
    now im tried in ios device, the file manager is also opened but no access for data all datas are no selectable why?
     
  23. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    The link I've posted mentions this issue. The issue is "ConvertExtensionToFileType("*")". You can try the solutions I've suggested in the link.
     
  24. HasithaCJ

    HasithaCJ

    Joined:
    May 20, 2017
    Posts:
    11
    When trying to share a screenshot to Facebook News Feed, FB app toast a message "Unable to share to Reals. To share this content, Create a post". This is only happen when trying to share to Facebook News Feed.
    It works well on trying to change FB profile pic, create FB story or send via other apps. I tried in android
     
  25. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    HasithaCJ likes this.
  26. HasithaCJ

    HasithaCJ

    Joined:
    May 20, 2017
    Posts:
    11
    yasirkula likes this.
  27. shoib_akthar

    shoib_akthar

    Joined:
    Oct 21, 2021
    Posts:
    4
    Hi, can you directly select a specific app like Gmail without showing all apps while sharing?
     
  28. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  29. lrudel_sega

    lrudel_sega

    Joined:
    Apr 27, 2016
    Posts:
    4
    @yasirkula Hi,
    I just wanted to ask if you are aware of the following crash and if you are planning to fix it?

    com.yasirkula.unity.NativeShareBroadcastListener.Initialize
    NativeShareBroadcastListener.java, line 32

    java.lang.IllegalArgumentException: : Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

    Overview
    Reports
    Stack traces
    • android.app.PendingIntent.checkFlags PendingIntent.java:382
    • android.app.PendingIntent.getBroadcastAsUser PendingIntent.java:673
    • android.app.PendingIntent.getBroadcast PendingIntent.java:660
    • com.yasirkula.unity.NativeShareBroadcastListener.Initialize NativeShareBroadcastListener.java:32
    • com.yasirkula.unity.NativeShareFragment.onCreate NativeShareFragment.java:42
    • android.app.Fragment.performCreate Fragment.java:2486
    • android.app.FragmentManagerImpl.moveToState FragmentManager.java:1261
    • android.app.FragmentManagerImpl.addAddedFragments FragmentManager.java:2431
    • android.app.FragmentManagerImpl.executeOpsTogether FragmentManager.java:2210
    • android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute FragmentManager.java:2166
    • android.app.FragmentManagerImpl.execPendingActions FragmentManager.java:2067
    • android.app.FragmentManagerImpl$1.run FragmentManager.java:742
    • android.os.Handler.handleCallback Handler.java:938
    • android.os.Handler.dispatchMessage Handler.java:99
    • android.os.Looper.loopOnce Looper.java:226
    • android.os.Looper.loop Looper.java:313
    • android.app.ActivityThread.main ActivityThread.java:8669
    • java.lang.reflect.Method.invoke Method.java
    • com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:571
    • com.android.internal.os.ZygoteInit.main ZygoteInit.java:1135
     
    Last edited: Sep 30, 2022
    Dalton-Lima and mkg2w like this.
  30. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  31. lrudel_sega

    lrudel_sega

    Joined:
    Apr 27, 2016
    Posts:
    4
    yasirkula likes this.
  32. ffdev78

    ffdev78

    Joined:
    Dec 18, 2020
    Posts:
    11
    Awesome plug-in! Is there a callback to check when you dismiss both the iOS Activity controller and Native Share on Android?

    I’m asking this because I’d like to hide some UI elements while sharing a screenshot, and after dismissing the share view I need to make them visible again (like a back or close button, you know)

    Thanks!
     
  33. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @ffdev78 Thanks! You can add your function to NativeShare object's SetCallback registrar.
     
    ffdev78 likes this.
  34. ashlit1998

    ashlit1998

    Joined:
    Jan 25, 2019
    Posts:
    10
    Hey yasirkula, thanks for creating this tool, it's been super helpful. There's a weird bug that's been going on with sharing links though.

    I use Firebase Dynamic links to share links to my game from any device, but basically whenever I try to shorten the link and send it through it causes the app to crash, telling me that there's a null reference exception going on. This happens inside the Android AJC.CallStatic line mentioned below. Do you know what I could look into to fix this: Thanks!
    Code (CSharp):
    1.         AJC.CallStatic( "Share", Context, new NSShareResultCallbackAndroid( callback ), targetPackages.ToArray(), targetClasses.ToArray(), files.ToArray(), mimes.ToArray(), emailRecipients.ToArray(), subject, CombineURLWithText(), title );
    2.  
     

    Attached Files:

  35. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @ashlit1998 Hi! Have you modified the source code? Does the error message contain more stacktrace information?
     
  36. ashlit1998

    ashlit1998

    Joined:
    Jan 25, 2019
    Posts:
    10
    Thank you for your quick reply! No, I haven't modified the source code. As for the stacktrace, the only info I was able to get is in the screenshot I'll attach here. Hope it's enough to help us find out where to start looking! Screen Shot 2022-10-21 at 10.02.36 AM.png
     
  37. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I'm not calling String.hashCode which confuses me. If you're calling Share from a separate thread, can you call it on main thread instead? Can I see your code to see if there are any lines that might cause issues?
     
  38. ashlit1998

    ashlit1998

    Joined:
    Jan 25, 2019
    Posts:
    10
    Sure, sorry for the late reply. Basically I'm calling ShortenLink after building the link as needed (which works but is simply long), and after it completes the SendLink fires off and lets us share the link. Supposedly, the SendLink won't fire until after we get the short link. Thanks again for your help!

    Code (CSharp):
    1.  
    2.         private void OnEnable()
    3.         {
    4.             onShortLinkReceived += SendLink;
    5.         }
    6.         private void OnDisable()
    7.         {
    8.             onShortLinkReceived -= SendLink;
    9.         }
    10.  
    11.         private void ShortenLink(DynamicLinkComponents components)
    12.         {
    13.             onShortLinkReceived?.Invoke(components.LongDynamicLink.ToString());
    14.             return;
    15.             var options = new Firebase.DynamicLinks.DynamicLinkOptions
    16.             {
    17.                 PathLength = DynamicLinkPathLength.Unguessable
    18.             };
    19.  
    20.             Firebase.DynamicLinks.DynamicLinks.GetShortLinkAsync(components, options).ContinueWith(task => {
    21.                 if (task.IsCanceled)
    22.                 {
    23.                     Debug.LogError("GetShortLinkAsync was canceled.");
    24.                     return;
    25.                 }
    26.                 if (task.IsFaulted)
    27.                 {
    28.                     Debug.LogError("GetShortLinkAsync encountered an error: " + task.Exception);
    29.                     return;
    30.                 }
    31.  
    32.                 // Short Link has been created.
    33.                 Firebase.DynamicLinks.ShortDynamicLink link = task.Result;
    34.                 Debug.LogFormat("Generated short link {0}", link.Url);
    35.                 onShortLinkReceived?.Invoke(link.Url.ToString());
    36.                 var warnings = new System.Collections.Generic.List<string>(link.Warnings);
    37.                 if (warnings.Count > 0)
    38.                 {
    39.                     // Debug logging for warnings generating the short link.
    40.                 }
    41.             });
    42.         }
    43.         private void SendLink(string linkToSend)
    44.         {
    45.             Debug.Log("Components string " + linkToSend);
    46.             GUIUtility.systemCopyBuffer = linkToSend;
    47.             Debug.Log("Copied link buffer");
    48.             NativeShare newNativeShare = new NativeShare();
    49.             Debug.Log("Created native share");
    50.             newNativeShare.SetText(linkToSend);
    51.             Debug.Log("Set text");
    52.             newNativeShare.Share();
    53.             Debug.Log("Sharing native share");
    54.         }
    55.  
    56.     }
     
  39. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Last edited: Oct 21, 2022
  40. ashlit1998

    ashlit1998

    Joined:
    Jan 25, 2019
    Posts:
    10
    So! Your intuition was right, and after a bit more digging it turns out firebase has something called firebase.extensions that adds another function called ContinueWithOnMainThread that I needed to use to actually be on the main thread. This seems to have fixed the problem, thank you for helping me debug it :D
     
    yasirkula likes this.
  41. MarcelPaladin

    MarcelPaladin

    Joined:
    Nov 2, 2021
    Posts:
    3
    Hello @yasirkula ! First: thank you for creating and maintaining NativeShare, it is a really nice plugin! We are using it in a pretty large (Live!) project and it mostly works really well. There is one issue we ran into though, with which I hope you can help us.
    On most devices running Android 12, we see a crash when returning to the app after sharing. I'll put what seems the most relevant part of our logs below this message.

    Some info we found on this ourselves, but can't really put our finger on what's wrong. Also: it would be likely the issue is either in Unity, or in the Java part of the NativeShare plugin, so it is hard to investigate.
    What we've tried so far:
    • Update to the latest version of NativeShare (1.4.7)
    • Delete NativeShare package as installed through Unity package manager, and reimported from the Unity package provided through GitHub
    • Add the READ_PHONE_STATE permission to the Android manifest
    • Update to the (at the time) latest Unity 2020 LTS version: 2020.3.37
    • Enable the 'mute other audio sources' option in the Android player settings
    None of the above worked unfortunately. Thanks in advance for any help you can offer! Below our crash log:

    Code (CSharp):
    1. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669] Pending exception java.lang.SecurityException: listen
    2. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at java.lang.Exception android.os.Parcel.createExceptionOrNull(int, java.lang.String) (Parcel.java:2437)
    3. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at java.lang.Exception android.os.Parcel.createException(int, java.lang.String) (Parcel.java:2421)
    4. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void android.os.Parcel.readException(int, java.lang.String) (Parcel.java:2404)
    5. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void android.os.Parcel.readException() (Parcel.java:2346)
    6. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void com.android.internal.telephony.ITelephonyRegistry$Stub$Proxy.listenWithEventList(int, java.lang.String, java.lang.String, com.android.internal.telephony.IPhoneStateListener, int[], boolean) (ITelephonyRegistry.java:1036)
    7. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void android.telephony.TelephonyRegistryManager.listenFromListener(int, java.lang.String, java.lang.String, android.telephony.PhoneStateListener, int, boolean) (TelephonyRegistryManager.java:250)
    8. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void android.telephony.TelephonyManager.listen(android.telephony.PhoneStateListener, int) (TelephonyManager.java:6798)
    9. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void com.unity3d.player.UnityPlayer.addPhoneCallListener() ((null):-1)
    10. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
    11. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) ((null):-1)
    12. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
    13. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
    14. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:226)
    15. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void android.os.Looper.loop() (Looper.java:313)
    16. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]   at void com.unity3d.player.UnityPlayer$e.run() ((null):-1)
    17. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669] Caused by: android.os.RemoteException: Remote stack trace:
    18. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]     at com.android.internal.telephony.TelephonyPermissions.enforceCarrierPrivilege(TelephonyPermissions.java:634)
    19. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]     at com.android.internal.telephony.TelephonyPermissions.checkReadPhoneState(TelephonyPermissions.java:149)
    20. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]     at com.android.internal.telephony.TelephonyPermissions.checkCallingOrSelfReadPhoneState(TelephonyPermissions.java:94)
    21. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]     at com.android.server.TelephonyRegistry.checkListenerPermission(TelephonyRegistry.java:3145)
    22. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]     at com.android.server.TelephonyRegistry.listen(TelephonyRegistry.java:1037)
    23. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]
    24. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669] (Throwable with no stack trace)
    25. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:669]
    26. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.SecurityException: listen
    27. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at java.lang.Exception android.os.Parcel.createExceptionOrNull(int, java.lang.String) (Parcel.java:2437)
    28. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at java.lang.Exception android.os.Parcel.createException(int, java.lang.String) (Parcel.java:2421)
    29. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void android.os.Parcel.readException(int, java.lang.String) (Parcel.java:2404)
    30. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void android.os.Parcel.readException() (Parcel.java:2346)
    31. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void com.android.internal.telephony.ITelephonyRegistry$Stub$Proxy.listenWithEventList(int, java.lang.String, java.lang.String, com.android.internal.telephony.IPhoneStateListener, int[], boolean) (ITelephonyRegistry.java:1036)
    32. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void android.telephony.TelephonyRegistryManager.listenFromListener(int, java.lang.String, java.lang.String, android.telephony.PhoneStateListener, int, boolean) (TelephonyRegistryManager.java:250)
    33. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void android.telephony.TelephonyManager.listen(android.telephony.PhoneStateListener, int) (TelephonyManager.java:6798)
    34. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void com.unity3d.player.UnityPlayer.addPhoneCallListener() ((null):-1)
    35. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
    36. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) ((null):-1)
    37. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
    38. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
    39. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:226)
    40. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void android.os.Looper.loop() (Looper.java:313)
    41. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]   at void com.unity3d.player.UnityPlayer$e.run() ((null):-1)
    42. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677] Caused by: android.os.RemoteException: Remote stack trace:
    43. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]     at com.android.internal.telephony.TelephonyPermissions.enforceCarrierPrivilege(TelephonyPermissions.java:634)
    44. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]     at com.android.internal.telephony.TelephonyPermissions.checkReadPhoneState(TelephonyPermissions.java:149)
    45. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]     at com.android.internal.telephony.TelephonyPermissions.checkCallingOrSelfReadPhoneState(TelephonyPermissions.java:94)
    46. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]     at com.android.server.TelephonyRegistry.checkListenerPermission(TelephonyRegistry.java:3145)
    47. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]     at com.android.server.TelephonyRegistry.listen(TelephonyRegistry.java:1037)
    48. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]
    49. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677] (Throwable with no stack trace)
    50. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]
    51. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]     in call to CallVoidMethodV
    52. 07-18 14:24:51.892 28838 28883 F ompany.packa: runtime.cc:677]     from boolean com.unity3d.player.UnityPlayer.nativeRender()
    53.  
     
  42. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Hi, could you remove NativeShare, build & run the game, minimize the running game (put it to background by going to home screen) and then maximize it back again (bring it back to foreground) and see if it crashes (on one of the problematic devices)?
     
  43. MarcelPaladin

    MarcelPaladin

    Joined:
    Nov 2, 2021
    Posts:
    3
    Thanks for your quick response, @yasirkula! I'll do that asap. (Will probably take a while, it's weekend now and I don't have access to an Android 12 device myself, but we'll get there.) I do believe though that we are able to go to the homescreen and back on builds with NativeShare in them, as long a we're not sharing. But I'll get back to you soon.
     
    yasirkula likes this.
  44. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    We had a crash with the same error message in our app (it wasn't using NativeShare) and the crash could be reproduced by minimizing and then maximizing the app. We resolved it with the "mute other audio sources" option in our case (it worked for us :oops:). At least we can see if you're experiencing the same NativeShare-independent crash.
     
  45. rbelchior

    rbelchior

    Joined:
    Mar 4, 2021
    Posts:
    2
    Hi @yasirkula, would you know of a way to share an image that exists as a game asset?
    I put the NativeShare to work with the sample code that takes a screenshot and shares it, but I'm wondering how I can share a predefined image I already have in my game assets?
     
  46. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @rbelchior Hi! You can pass Texture2D to AddFile function.
     
  47. rbelchior

    rbelchior

    Joined:
    Mar 4, 2021
    Posts:
    2
    That's true @yasirkula and I was already trying to use it that way, but I was trying to load the asset in a weird way, my bad!
    Looked at it again, and I just put the Texture2D as a property in my script and then I'm passing it along to the NativeShare plugin and it works like a charm. Thanks!
     
    yasirkula likes this.
  48. mkg2w

    mkg2w

    Joined:
    Aug 19, 2013
    Posts:
    54
    We used the latest 1.4.7 version, but see the same Exceptions reported on Android 12 devices.


    Code (CSharp):
    1. java.lang.IllegalArgumentException: com.games2win.decisions: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    2. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    3.         at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
    4.         at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
    5.         at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
    6.         at com.yasirkula.unity.NativeShareBroadcastListener.Initialize(NativeShareBroadcastListener.java:33)
    7.         at com.yasirkula.unity.NativeShareFragment.onCreate(NativeShareFragment.java:42)
    8.         at android.app.Fragment.performCreate(Fragment.java:2486)
    9.         at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1261)
    10.         at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2431)
    11.         at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2210)
    12.         at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2166)
    13.         at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2067)
    14.         at android.app.FragmentManagerImpl$1.run(FragmentManager.java:742)
    15.         at android.os.Handler.handleCallback(Handler.java:938)
    16.         at android.os.Handler.dispatchMessage(Handler.java:99)
    17.         at android.os.Looper.loopOnce(Looper.java:226)
    18.         at android.os.Looper.loop(Looper.java:313)
    19.         at android.app.ActivityThread.main(ActivityThread.java:8751)
    20.         at java.lang.reflect.Method.invoke(Method.java:-2)
    21.         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    22.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
     
  49. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @mkg2w Where did you download the plugin from? If Asset Store, please download it from GitHub.
     
  50. MarcelPaladin

    MarcelPaladin

    Joined:
    Nov 2, 2021
    Posts:
    3
    Sorry for the delay. I did not actually remove NativeShare yet, but simply asked someone to test backgrounding the app on an Android 12 device that had the crash. This indeed seems to cause a crash as well. To me that is sufficient indication that NativeShare may have nothing to do with this at all. I will investigate some more, but in any case, thank you so much for your answer, this apparently had me on the wrong track!
     
    yasirkula likes this.
Thread Status:
Not open for further replies.