Development

Step 1: Open project file

  1. Open the Android Studio.

  2. Click on the Open an existing Android Studio project option. If mastercard-sharehome-android project is already open, jump to 5.

  3. If some other project is already open, click File -> Open.

  4. Open the mastercard-sharehome-android project.

    • For Windows workstation: C:\{APP_DIRECTORY}\ShareHome\mastercard-sharehome-android

    • For Linux workstation: ./{APP_DIRECTORY}/ShareHome/mastercard-sharehome-android

  5. Wait a couple of minutes until the whole project is loaded.

Step 2: Code implementation

  1. Initiate requests for scopes when user clicks Continue with ID button.

    • Analyze the application flow and find in source code the place to put the corresponding code fragment

    • Use RPClaimRequestBuilder class to create request with proper scopeType

    • Test if there is a proper result redirecting to Samsung Pass application

    LoginActivity.kt

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)
        findViewById<ImageButton>(R.id.btnId)
            .setOnClickListener(View.OnClickListener {
            RPClaimRequestBuilder().requestForScopes(this, ScopeType.NameAddressDoB)
        })
    }
    

  2. Handle the response with requested scope from Samsung Pass application.

    • Find usage of method handlerScopeResponse

    • Fill callback, so that requested scopes are combined as single String separated with \n

    • Forward result to PaymentActivity class. Use intent.putExtra with key "ReturnedScope"

    • Check if PaymentActivity shows requested data

    SplashActivity.kt

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)
    
        if (intent.action == Intent.ACTION_VIEW) {
            (intent.data as? Uri)?.let {
                RPClaimResponseParser().handlerScopeResponse(this, it, { scopes ->
                    val scopeDetails = scopes.map { scope -> scope.value }.joinToString { "\n" + it }
                    println(scopeDetails)
    
                    finishAffinity()
    
                    var intent = Intent(this, PaymentActivity::class.java)
                    intent.putExtra("ReturnedScope", scopeDetails)
                    startActivity(intent)
                })
            }
        } else {
            Handler().postDelayed(Runnable {
                finish()
                val intent = Intent(this, MainActivity::class.java)
                startActivity(intent)
            }, 1000)
        }
    }
    

Step 3: Deployment

  1. In the top menu bar click: Build -> Make project.

  2. Connect the Samsung Galaxy device to the workstation via USB. Click Allow if you see a pop-up on the Galaxy device.

  3. Run the project.

  4. Select the Galaxy device as a deployment target. Do not deploy the project on any emulator. Click the OK button.

  5. The project has been deployed on the Galaxy device.

  6. Close the mastercard-sharehome-android project: File -> Close Project.

You're done!

Congratulations! You have successfully achieved the goal of this Code Lab activity. Now, you can provide specific authorized user data from Digital ID by yourself! But, if you're having trouble, you may check out the link below.

ShareHome App Complete Code8.44 MB