Android

Integrate Ramp Instant widget into your Android application

The Android SDK allows you to seamlessly open the Ramp Instant widget directly inside your app using WebViews. Your app will be able to receive events about the purchase made inside the widget.

Useful links:


Prerequisites

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}

Add this to your module's build.gradle file:

dependencies {
  ...
  implementation 'com.github.RampNetwork:ramp-instant-sdk-android:v0.3.0'
}

Add this in your AndroidManifest.xml file:

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

    <application ... >
      // ...
        <activity
            android:name="network.ramp.instantsdk.ui.bank.BankActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@style/RampInstant.NoActionBar" />
        <activity
            android:name="network.ramp.instantsdk.ui.rampinstant.RampInstantActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@style/RampInstant.NoActionBar"></activity>
      // ...
     </application>

Example integration code

// ...
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_deposit.*
import network.ramp.instantsdk.R
import network.ramp.instantsdk.facade.RampInstantSDK


class DemoActivity : AppCompatActivity() {

    private lateinit var widget: RampInstantSDK

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

        buyWithRampButton.setOnClickListener {
            widget = RampInstantSDK(
                this,
                swapAsset: "ETH",
                swapAmount: "1500000000000000000", // 1.5 ETH in wei
                userAddress: "0xab5801a7d398351b8be11c439e05c5b3259aec9b",
                hostLogoUrl: "https://yourdapp.com/yourlogo.png",
                hostAppName: "Your Dapp",
                webhookStatusUrl: "https://my.domain/callback/123/"
                url = "https://ri-widget-dev.firebaseapp.com", // Use development environment
            )
            widget.show()
        }
    }
}