GithubHelp home page GithubHelp logo

baba-s / uniandroidintent Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 2.0 34 KB

【Unity】adb shell am start で Android アプリを起動した時に指定された引数を解析する機能

License: MIT License

C# 100.00%
unity unity3d unity-mobile unity-android unity-test unity-ci kogane-unity-lib

uniandroidintent's Introduction

Uni Android Intent

adb shell am start で Android アプリを起動した時に指定された引数を解析する機能

manifest.json に上記の記述を追加します

使用例

adb shell am start ^
    -n com.baba-s.uniandroidintent/com.unity3d.player.UnityPlayerActivity ^
    --ei i 123 ^
    --el l 456 ^
    -e s ABC ^
    --ez b true ^
    --eia ia 111,223,343 ^
    --ela la 444,555,666 ^
    --esa sa AAA,BBB,CCC

adb shell am start を使用して、引数付きで Android アプリを起動した場合に

// int 型の値を取得
Debug.Log( AndroidIntent.GetInt( "i" ) );

// long 型の値を取得
Debug.Log( AndroidIntent.GetLong( "l" ) );

// string 型の値を取得
Debug.Log( AndroidIntent.GetString( "s" ) );

// bool 型の値を取得
Debug.Log( AndroidIntent.GetBool( "b" ) );

// int 型の配列を取得
foreach ( var n in AndroidIntent.GetIntArray( "ia" ) )
{
    Debug.Log( n );
}

// long 型の配列を取得
foreach ( var n in AndroidIntent.GetLongArray( "la" ) )
{
    Debug.Log( n );
}

// string 型の配列を取得
foreach ( var n in AndroidIntent.GetStringArray( "sa" ) )
{
    Debug.Log( n );
}

このようなコードで引数を解析して使用できます

adb shell am start の引数の指定方法

指定方法
int --ei 【引数名】 【引数の値】
long --el 【引数名】 【引数の値】
string -e 【引数名】 【引数の値】
bool --ez 【引数名】 【引数の値】
int の配列 --eia 【引数名】 【配列の値(カンマ区切り)】
long の配列 --ela 【引数名】 【配列の値(カンマ区切り)】
string の配列 --esa 【引数名】 【配列の値(カンマ区切り)】

用途

  • 例えば、Jenkins などでアプリを自動ビルドした後に
    そのアプリを Android 端末に自動でインストールして
    さらに自動でエージングテストを実行することで、
    ビルドしたアプリが正常に動作するかどうか確認する、といった場面で使用できます

参考サイト様

uniandroidintent's People

Contributors

baba-s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.