📃
OmniOne Developer Site
  • Introduction
  • Manager console guide
    • To begin with...
      • Wallet Settings
      • Select an Account
      • The Issuer/SP account creation
      • Issue access token for the OmniOne Agent
    • Issuer Console
      • Claim
      • VC Type
      • VC Format
      • Issue the VC Information
      • My request list
    • SP Console
      • Service List
      • Token Transaction History
      • My service request
  • Server system construction
    • To begin with...
      • Server Wallet creation and Key settings
      • Collect the Issuer and SP's DID
      • application.properties settings
    • Server default environment configuration per IDE
      • Spring Tool Suite 4
      • IntelliJ IDEA
    • Building the Issuer system
      • Issuer server guide(JAVA)
    • Building the SP system
      • SP server guide (JAVA)
  • Checking Blockchain data
    • Check Agent API
      • bp
      • Committee
      • DID
      • executor
      • key
      • pDID
      • player
      • policy
      • txinfo
      • txissue
      • vc
      • version
      • response codes
  • SDK instruction guide
    • Core SDK Guide
      • Java Wallet
        • IWKeyManager
        • IWDIDManager
        • IWRecoveryManager
        • ZkpException
        • IWException
      • iOS Wallet
        • IWKeyManager
        • IWDidManager
        • IWClaimManager
        • IWRecoveryManager
        • IWErrorManager
        • Enum
    • Server SDK Guide
      • Java
        • ServerInfo
        • IssuerApi
        • SpApi
        • VcResult
        • VcInitParam
        • VCRegParam
        • VcVerifyParam
        • SpProfileParam
    • Omni App Link SDK
      • Server
      • Android
      • IOS
  • Node creation
    • Full Node creation
      • Full Node by using Docker
        • Docker Installation
        • Building Full Node
        • Full Node settings
      • Installation type Full Node
        • Full Node installation
    • BP Node creation
      • BP Node by using Docker
        • Docker Installation
        • Building BP Node
        • BP Node settings
          • keosd/BP Node executing simultaneously
      • Installation type BP
        • Node Installation
        • Executing Node
        • Node settings
        • BP Vote
Powered by GitBook
On this page
  • 1. Omnilink import and settings
  • 2. AndroidManifest.xml settings
  • 3. Host, Scheme setting
  • 4. API
  • 4.1 Create
  • 4.2 setPackageName
  • 4.3 setActivity
  • 4.4 callApp
  • 4.5 returnResult
  • 4.6 receiveResult
  • 4.7 isExistPackage
  • 4.8 exit
  • 5. Sample source
  • 5.1 MainActivity.kt (Transmitting App)
  • 5.2 MainActivity.kt (Target App)

Was this helpful?

  1. SDK instruction guide
  2. Omni App Link SDK

Android

PreviousServerNextIOS

Last updated 4 years ago

Was this helpful?

1. Omnilink import and settings

Copy arr library file in the libs folder of App-level directory (create if missing)

After, Add arr file and additional library as below.

2. AndroidManifest.xml settings

Add Internet permission for servlet communication.

<uses-permission android:name="android.permission.INTERNET" />

3. Host, Scheme setting

<activity android:name=".MainActivity"
    android:launchMode="singleTask"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="adjustNothing">

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:scheme="your app scheme"
            android:host="your app host" />
    </intent-filter>
</activity>
  • launchMode of Activity will not operate properly, if it is not a "singleTask" on a specific browser.

  • The scheme, host, and past MUST be equal to set items on RSBridge for JSP.

  • scheme uses the custom scheme like "rsbsample" and Android may be able to use a known scheme such as "http", "https".

  • scheme can apply more than one as shown as the above example. At this time, intent-filter may be able to create separately depending on whether the host and path.

4. API

4.1 Create

CLASS

Content

Purpose

Creator for initial implementation

Use

OmniLinkManager(this, OmniLinkListener)

Parameter

Activity, OmniLinkListener

Return

void

Example

var omniLinkManager = OmniLinkManager(this, object: OmniLinkListener {

override fun receive(data: String) {

}

override fun sendFinish() {

}

})

Note

  • Creator

4.2 setPackageName

CLASS

Content

Purpose

Redirects to the market, when target App is not stored on the device

Use

setPackageName(String)

Parameter

packageName

Return

void

Example

omniLinkManager.setPackageName(“target package name”)

Note

  • Use the transmitting App

  • Returns the error msg when the Package is not saved

4.3 setActivity

CLASS

Content

Purpose

Use when the target App already exists in the Os stack

Use

setActivity(Activity)

Parameter

activity

Return

void

Example

omniLinkManager.setActivity(this)

Note

  • uses the target App

4.4 callApp

CLASS

Content

Purpose

Use when calling and forward data from the transmitting App to the target App

Use

callApp(String, String, String, String)

Parameter

host, scheme, type, select

Return

void

Example

omniLinkManager.callApp(this)

Note

  • Uses the transmitting App

4.5 returnResult

CLASS

Content

Purpose

Forwards the Result data to the transmitting App

Use

callApp(OmniLinkData)

Parameter

omniLinkData

Return

void

Example

omniLinkManager.returnResult(omniLinkData)

Note

  • Uses the target App

4.6 receiveResult

CLASS

Content

Purpose

parsing the delivered data from the target app to transmitting app

Use

receiveResult(Int, Int, Intent)

Parameter

requestCode, resultCode, intent

Return

void

Example

omniLinkManager.receiveResult(requestCode, resultCode, intent)

Note

  • Uses the transmitting App

4.7 isExistPackage

CLASS

Content

Purpose

Checks if an App in that package exists in the device

Use

isExistPackage(Context, String)

Parameter

context, packageName

Return

Boolean

Example

Util.isExistPackage(context, “package name”)

Note

  • Uses transmitting App

  • Uses target App

4.8 exit

CLASS

Content

Purpose

After exiting an App, removes the termination app in the OS stack

Use

exit(Activity)

Parameter

activity

Return

void

Example

Util.exit(this)

Note

  • Uses the transmitting App

5. Sample source

5.1 MainActivity.kt (Transmitting App)

class MainActivity : AppCompatActivity() {
    private val mPackageName = "com.omnioneltd.receiveapp"
    private val mToAppHost = "receivehost"
    private val mToAppScheme = "receivescheme"

    private lateinit var mOmniLinkManager : OmniLinkManager

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // create ToApp
        mOmniLinkManager = OmniLinkManager(this, object: OmniLinkListener {
            override fun receive(data: String) {
                // receive from app or request error code
                val resultData = OmniLinkData(data)
                if(Codes.success == resultData.code){
                    printLog("success receive : ${resultData.toJson()}")
                } else {
                    printLog("error receive : ${resultData.toJson()}")
                }
            }

            override fun sendFinish() {
                // work finish
                printLog("finish")
            }
        })

        // if does not exist response app in phone. go to market
        mOmniLinkManager.setPackageName(mPackageName)

        log.movementMethod = ScrollingMovementMethod()

        user_auth_btn.setOnClickListener { v ->
            // does check exist response app
            if(Util.isExistPackage(this@MainActivity, mPackageName)){
                pickContact()
            } else {
                printLog("does not exist $mPackageName")
            }
        }

        did_auth.setOnClickListener { v ->
            pickContact()
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        // receive check
        mOmniLinkManager.receiveResult(requestCode, resultCode, data)
    }

    private fun pickContact() {
        // call app
        mOmniLinkManager.callApp(mToAppHost, mToAppScheme, Type.DID_AUTH, "select type")
    }

    fun printLog(text: String) {
        if(log.text == null || log.layout == null || log.lineCount == null){
            return
        }

        log.text = log.text.toString() + "\n" + text
        val scrollY = log.layout.getLineTop(log.lineCount) - log.height
        if (scrollY > 0) {
            log.scrollTo(0, scrollY)
        }
    }
}

5.2 MainActivity.kt (Target App)

class MainActivity : AppCompatActivity() {
    lateinit var mOmniLinkManager : OmniLinkManager

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)

        // it's running this app
        mOmniLinkManager.setActivity(this)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // create ToApp
        mOmniLinkManager = OmniLinkManager(this, getToAppListener())

        log.movementMethod = ScrollingMovementMethod()

        callback.setOnClickListener {
            // make callback message
            OmniLinkData().let {
                val code = code.text.toString()
                val msg = msg.text.toString()
                val data = data.text.toString()

                it.code = if(TextUtils.isEmpty(code)) Codes.success else code.toInt()
                it.msg = if(TextUtils.isEmpty(msg)) "success" else msg
                it.data = if(TextUtils.isEmpty(data)) "Check the information in the existing app." else data

                mOmniLinkManager.returnResult(it)
            }
        }
    }

    private fun getToAppListener(): OmniLinkListener {
        return object: OmniLinkListener {
            override fun receive(data: String) {
                // receive from app or request error code
                val resultData = OmniLinkData(data)
                if(Codes.success == resultData.code){
                    Handler().postDelayed({
                        printLog("success receive : ${resultData.toJson()}")
                    }, 1000)
                } else {
                    printLog("error receive : ${resultData.toJson()}")
                }
            }

            override fun sendFinish() {
                // work finish
                printLog("finish")
                this@MainActivity.finish()
            }
        }
    }

    fun printLog(text: String) {
        if(log.text == null || log.layout == null || log.lineCount == null){
            return
        }

        log.text = log.text.toString() + "\n" + text
        val scrollY = log.layout.getLineTop(log.lineCount) - log.height
        if (scrollY > 0) {
            log.scrollTo(0, scrollY)
        }
    }
}