Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennethljj/a859322bb0b11d70c93e to your computer and use it in GitHub Desktop.
Save kennethljj/a859322bb0b11d70c93e to your computer and use it in GitHub Desktop.
In order to take part in the Unity Activity sharing system, there are a few steps you will need to take outlined below. First, some background. You can signify which class you would like to receive all the Activity lifecycle methods. When you implement the methods they should have the exact same signature but they should be *public static void*. That is important! They will not be called if they are not public static void. You can implement 1 or all of the methods. That is entirely up to your needs.
1. Download the Prime31UnityActivity.jar file from here: https://app.box.com/s/xw6hq1ltjaniycc14j21 You are free to distribute the file but *do not change it's name*! That would defeat the purpose of the sharing mechanism!
2. Implement any of the methods that are available in this Gist (https://gist.github.com/prime31/10747997)
3. Perform the AndroidManifest changes below
If successful, on app launch you will see a log that looks like the following:
found Activity proxy class: com.yourpackage.yourclass
Note for plugin vendors: one really simple way to have your plugin "just work" when the Activity sharing system is being used is to perform steps 1 and 2 above and only add the meta-data line to the AndroidManifest. By doing that your plugin will work as it does currently and when the Activity sharing system is being used by the end user.
Manifest Changes:
- add the following line to the AndroidManifest replacing the "com.yourpackage.yourclass" with the full qualified name of the class that you would like to be notified of Activity lifecycle methods.
<meta-data android:name="com.yourpackage.yourclass" android:value="UnityPlayerActivityProxy"/>
- add the following Activity:
<activity android:name="com.prime31.UnityPlayerNativeActivity"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment