- If you have any questions/comments, please visit Pico Developer Answers and raise your question there.
This project incorporates most of our Android repositories into one single package, and categorizes all interfaces into 6 classes: DeviceHelper
, StorageHelper
, BlueToothHelper
, WifiHelper
, PowerManagerHelper
, AudioHelper
.
Knowledge of Unity Scripting API: AndroidJavaObject
-
Clone this repo and make project in Android Studio, or download aar file in release page.
-
Put
AndroidHelper_Vx.x.x.aar
into your Unity project's Assets/Plugins/Android directory; -
Refer to the sample code below to call the interface.
//Initialize an AndroidJavaObject with the class name of the interface, //e.g., DeviceHelper, StorageHelper, BlueToothHelper, WifiHelper, PowerManagerHelper. AndroidJavaObject deviceHelper= new AndroidJavaObject("com.picovr.androidhelper.DeviceHelper"); //Get current activity AndroidJavaObject activityContext = new AndroidJavaClass("com.unity3d.player.UnityPlayer") .GetStatic<AndroidJavaObject>("currentActivity"); //Must call "init" method before call other interface. deviceHelper.Call("init", activityContext ); //Call the interface. string puiVersion = deviceHelper.Call<string>("getPUIVersion");
The interface marked with star "(*)" requires the system signature.
Refer to the following steps to sign you APK using Pico system signature:
-
Add sharedUserId in
AndroidManifest.xml
in Assets/Plugins/Android(If you are using Unity 2019.3.x and above,this directory should be [Unity_PATH]\Editor\Data\PlaybackEngines\AndroidPlayer\Apk\LauncherManifest.xml).<manifest ... android:sharedUserId="android.uid.system"> ... </manifest>
-
Refer to online instruction to sign your apk with system signature.
The installApp
API use AndroidX
support library which may cause conflict if there is another support libraty in your unity project. To resolve this problem, use "AndroidHelper_vx.x.x_nxs.aar" (no androidx support) in release page. This AAR removed the androidx support library and related reference. Note that the installApp
API won't work anymore after doing this.
Note: The interface marked with star "(*)" requires the APK has the system signature
- getPUIVersion: get PUI version of device.
- getDeviceType: Get type of device.
- getSN (*): Get serial number of device.
- silentInstall (*): Install the application without user interaction.
- silentUninstall (*): Uninstall the application without user interaction.
- killApp: Kill the application.
- launchBrowser: Call specified browser to open the link.
- launchBrowserWithLinkInFile: Call specified browser to open the link in the file.
- goToApp: Start an application.
- startVRShell: Launch Android 2D application.
- getAppList: Get a name list of installed applications.
- registerHomeReceiver: Register the receiver of Home event broadcast.
- unregisterHomeReceiver: Unregister the receiver of Home event broadcast.
- openRecenterApp: Adjust startup calibration application.
- installApp: Install the application.
- setSystemProp: Set specified system property.
- getSystemProp: Get specific system property.
- getStorageFreeSize: The remaining storage space inside the device.
- getStorageTotalSize: Total storage space inside the device.
- updateFile: Update storaged file.
- getSDCardPath: Get SD card path.
- registerBlueToothReceiver: Register the receiver of bluetooth status broadcast.
- unregisterBlueToothReceiver: Unregister the receiver of bluetooth status broadcast.
- getContentDevice: Get the name of connected bluetooth.
- getBlueToothMac (*): Get the MAC address of connected bluetooth.
- registerWifiReceiver: Register the receiver of Wi-Fi status broadcast.
- unregisterWifiReceiver: Unregister the receiver of Wi-Fi status broadcast.
- getConnectedWifiSSID: Get the name of Wi-Fi connection.
- getWifiMac: Get the MAC address of connected Wi-Fi.
- getWifiIpAddress: Get Wi-Fi IP address.
- connectWifi (*): Connect to Wi-Fi.
- connectWifiWithStaticIP: Set static IP.
- androidLockScreen: Lock the screen.
- androidUnLockScreen: Unlock the screen.
- acquireWakeLock: Request a WakeLock.
- acquireWakeLock(timeout): Request a WakeLock, unlock automatically after timeout.
- releaseWakeLock: Deactivate WakeLock.
- setPropSleep: Sets System Sleep Timeout.
- setPropScreenOff: Sets Screen Off Timeout.
- androidShutDown (*): Shutdown the system.
- androidReBoot (*): Reboot the system.
- startRecordByMIC: Start recording audio via mic.
- stopRecordByMIC: Stop recording audio via mic.