Code Monkey home page Code Monkey logo

androidhelper's Introduction

Android Helper

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.

Prerequirement

Knowledge of Unity Scripting API: AndroidJavaObject

Usage

  1. Clone this repo and make project in Android Studio, or download aar file in release page.

  2. Put AndroidHelper_Vx.x.x.aar into your Unity project's Assets/Plugins/Android directory;

  3. 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");

System Signature

The interface marked with star "(*)" requires the system signature.

Refer to the following steps to sign you APK using Pico system signature:

  1. 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>
  2. Refer to online instruction to sign your apk with system signature.

Resolve Android support library conflict

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.

Interfaces

Note: The interface marked with star "(*)" requires the APK has the system signature

DeviceHelper

StorageHelper

BlueToothHelper

WifiHelper

PowerManagerHelper

AudioHelper

androidhelper's People

Contributors

picoxr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.