{"id":18862910,"url":"https://github.com/bayatgames/android-social-sharing","last_synced_at":"2026-05-09T10:20:53.715Z","repository":{"id":197476090,"uuid":"698594179","full_name":"BayatGames/android-social-sharing","owner":"BayatGames","description":"A social sharing library for Android","archived":false,"fork":false,"pushed_at":"2023-10-23T04:41:00.000Z","size":288,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-30T21:17:04.258Z","etag":null,"topics":["android","library","native","share","sharing","social","unity","unity3d"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BayatGames.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-30T11:34:07.000Z","updated_at":"2024-09-04T19:28:11.000Z","dependencies_parsed_at":"2023-10-15T03:43:57.699Z","dependency_job_id":"13ab8691-2df7-4b05-be03-9080a230b16a","html_url":"https://github.com/BayatGames/android-social-sharing","commit_stats":{"total_commits":30,"total_committers":1,"mean_commits":30.0,"dds":0.0,"last_synced_commit":"34d13bf5ef8ec119c58f90f3d8ff915aae44bb30"},"previous_names":["bayatgames/io.bayat.android.social.sharing","bayatgames/android-social-sharing"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BayatGames%2Fandroid-social-sharing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BayatGames%2Fandroid-social-sharing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BayatGames%2Fandroid-social-sharing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BayatGames%2Fandroid-social-sharing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BayatGames","download_url":"https://codeload.github.com/BayatGames/android-social-sharing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239808152,"owners_count":19700440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","library","native","share","sharing","social","unity","unity3d"],"created_at":"2024-11-08T04:36:10.947Z","updated_at":"2026-02-10T17:30:14.879Z","avatar_url":"https://github.com/BayatGames.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android Social Sharing Library\n\n[![Publish](https://github.com/BayatGames/android-social-sharing/actions/workflows/publish.yml/badge.svg)](https://github.com/BayatGames/android-social-sharing/actions/workflows/publish.yml) [![Release](https://jitpack.io/v/BayatGames/android-social-sharing.svg)](https://jitpack.io/#BayatGames/android-social-sharing)\n\nA social sharing library for Android.\n\nActively maintained.\n\n## Features\n\n- Uses Builder pattern\n- Provides a convenient interface to be used in Unity as a native plugin or JNI\n- Supports Sharesheet/Chooser\n- Supports basic sharing\n- Supports HTML text and literal text (prefilled text, some social platforms do not support it)\n- Supports binary content (such as images)\n- Supports custom mime type\n- Aimed for JNI and native bridge usages\n- Available on Maven Central, Jitpack and GitHub packages\n- Uses [`ShareCompat.IntentBuilder`](https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentBuilder)\n- Provides custom methods for Unity\n\n## Installation\n\nArtifact is available on Maven Central, Jitpack and GitHub packages.\n\n```groovy\nio.bayat.android:social-sharing:1.1.0\nio.bayat.android:social-sharing-unity:1.1.0\n```\n\n### Gradle Setup\n\n- Add as a dependency:\n\n```groovy\ndependencies {\n    implementation \"io.bayat.android:social-sharing:1.1.0\"\n\n    ... // Other dependencies\n}\n```\n\n### Unity Setup\n\n1. Install [External Dependency Manager for Unity](https://github.com/googlesamples/unity-jar-resolver)\n2. Add the dependency to your dependencies xml file to your Unity project:\n\n    ```xml\n    \u003cdependencies\u003e\n        \u003candroidPackages\u003e\n            \u003candroidPackage spec=\"io.bayat.android:social-sharing-unity:1.1.0\" /\u003e\n        \u003c/androidPackages\u003e\n    \u003c/dependencies\u003e\n    ```\n\n3. Use it through [Android JNI](https://docs.unity3d.com/Manual/android-plugins-java-code-from-c-sharp.html)\n\n## Usage\n\n### Android Usage\n\nUse the `SocialSharing.Builder` to create a `SocialSharing` instance:\n\n```java\nString mimeType = \"text/plain\";\nString message = \"Hello World\";\nSocialSharing sharing = new SocialSharing.Builder(myActivity)\n        .setText(message)\n        .setType(mimeType)\n        .build();\n```\n\n- **Sharesheet**: Call `setUseSharesheet(true)` to use Android's Sharesheet:\n\n```java\nString mimeType = \"image/jpeg\";\nString message = \"Hello World\";\nSocialSharing sharing = new SocialSharing.Builder(myActivity)\n        .setText(message)\n        .setStream(Uri.fromFile(new File(\"/sdcard/cats.jpg\"))\n        .setType(mimeType)\n        .build();\n\n// Call send method\nsharing.send(myActivity);\n```\n\n- **Basic**: Call `setUseSharesheet(false)` to use basic sharing:\n\n```java\nString mimeType = \"image/jpeg\";\nString message = \"Hello World\";\nSocialSharing sharing = new SocialSharing.Builder(myActivity)\n        .setText(message)\n        .setStream(Uri.fromFile(new File(\"/sdcard/cats.jpg\"))\n        .setType(mimeType)\n        .build();\n\n// Call send method\nsharing.send(myActivity);\n```\n\n### Unity Usage\n\nThe `SocialSharingUnity` extends from `SocialSharing` so it extends the `Builder` too, the only differences are the URI and the `send` method:\n\n```java\nString mimeType = \"image/jpeg\";\nString message = \"Hello World\";\nSocialSharingUnity sharing = new SocialSharingUnity.Builder()\n        .setText(message)\n        .setUnityStream(\"myscreenshot.jpg\")\n        .setType(mimeType)\n        .build();\n\n// Call send method, the activity parameter is not required as the SocialSharingUnity will use the current activity of UnityPlayer\nsharing.send();\n```\n\nAlso for JNI use cases, use this class and the methods of `setUnityStream` and `addUnityStream` for specifying files and content to be shared instead of `setUri` or `addUri`:\n\n```csharp\nconst string BuilderClassName = \"io.bayat.android.social.sharing.unity.SocialSharingUnity$UnityBuilder\";\n\nbool useSharesheet = true;\nbool useRichPreview = true;\nstring text = \"Hello World from Unity!\";\nstring title = \"My Custom Chooser Title\";\nstring imagePath = Application.persistentDataPath + \"/screenshot.jpg\";\nstring mimeType = \"image/jpg\";\n\nusing (AndroidJavaObject builder = new AndroidJavaObject(BuilderClassName))\n{\n    builder.Call\u003cAndroidJavaObject\u003e(\"setText\", text);\n    builder.Call\u003cAndroidJavaObject\u003e(\"setChooserTitle\", title);\n    builder.Call\u003cAndroidJavaObject\u003e(\"setUnityStream\", imagePath);\n    builder.Call\u003cAndroidJavaObject\u003e(\"setType\", data.MimeType);\n    builder.Call(\"startChooser\");\n}\n```\n\n## API\n\n### SocialSharing\n\n- `send(Activity activity)`: Send the content to be shared using the given Activity\n\n#### SocialSharing.Builder\n\n- `setText(String text)`: Set the text to be shared\n- `setHtmlText(String htmlText)`: Set the HTML text to be shared (the HTML text is parsed before sharing, useful for formatting)\n- `setStream(Uri uri)`: Set the URI of the content to be shared\n- `addStream(Uri uri)`: Add a URI to the content to be shared\n- `setChoosterTitle(String title)`: Set the sharesheet/chooser title\n- `setType(String type)`: Set the mime type of the content to be shared\n- `build()`: Build the `SocialSharing` instance\n- `startChooser`: Start the sharesheet/chooser activity\n\n### SocialSharingUnity\n\n- `send()`: Send the content to be shared (uses UnityPlayer.currentActivity as the Activity)\n\n#### SocialSharingUnity.Builder\n\nExtends from `SocialSharing.Builder` and adds the following methods:\n\n- `setUnityStream(String path)`: Set the URI of the content to be shared from a Unity (resolves the file path to a content URI in Android)\n- `addUnityStream(String path)`: Add a URI to the content to be shared from a Unity (resolves the file path to a content URI in Android)\n\n## Notes\n\nThe `setText` method sets a prefilled text to be shared by the user, but some social platforms do not support it, mainly **Facebook** amd all of their other various social services including **Instagram**, **Messenger**, **WhatsApp** and **Facebook Lite**, but other platforms such as **Twitter**, **Discord**, **Slack** and others support it. (this won't have any issues on your app, it will just ignore the text and share the content without it)\n\n[Learn more on Meta Platform Terms](https://developers.facebook.com/terms/) and [Platform Policy 2.3 Example and Explanation](https://developers.facebook.com/docs/apps/review/prefill)\n\n## Changelog\n\nCheck the [CHANGELOG.md][changelog] file for more information.\n\n## Resources\n\n- [Android - Send simple data to other apps](https://developer.android.com/training/sharing/send)\n- [Call Java and Kotlin plug-in code from C# scripts](https://docs.unity3d.com/Manual/android-plugins-java-code-from-c-sharp.html)\n- [NicholasSheehan/Unity-Native-Sharing](https://github.com/NicholasSheehan/Unity-Native-Sharing)\n\n## License\n\nCheck the [LICENSE][license] file for more information.\n\n## Credits\n\n- Developed and maintained by [Hasan Bayat][hasanbayat]\n\nMade with ❤️ by [Bayat][bayat]\n\n[changelog]: ../blob/main/CHANGELOG.md\n[license]: ../blob/main/LICENSE\n[bayat]: https://bayat.io\n[hasanbayat]: https://github.com/hasanbayatme\n[bayatgames]: https://github.com/BayatGames\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbayatgames%2Fandroid-social-sharing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbayatgames%2Fandroid-social-sharing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbayatgames%2Fandroid-social-sharing/lists"}