For the complete documentation index, see llms.txt. This page is also available as Markdown.

Android Development

IC4J Agent library can be also used for development of native Android application written in Java or Kotlin. Use Android Studio to start a new Android application or add support for the Internet Computer to your existing application.

To add required IC4J libraries to your Android project open gradle.build file and add dependencies:

    implementation 'commons-codec:commons-codec:1.17.0'
    implementation 'org.ic4j:ic4j-candid:0.8.0'
    implementation('org.ic4j:ic4j-agent:0.8.0') {
        exclude group: 'org.apache.httpcomponents.client5', module: 'httpclient5'
    }
    implementation 'org.slf4j:slf4j-api:2.0.13'

Android application preferably uses OkHttp HTTP client so Apache HTTP 5 library can be excluded.

To be able to connect to the Internet Computer Canister set uses-permission in project AndroidManifest.xml descriptor.

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

Use IC4J with Kotlin

AndroidHelloWord sample application demonstrates use or QueryBuilder and UpdateBuilder in Kotlin Android project. Project properties ic.location and ic.canister are stored in strings.xml file.

MainActivity.kt has a simple code for QUERY and UPDATE invocation of the Canister code main.mo.

main.mo
actor {
    stable var name = "Me";

    public func greet(value : Text) : async Text {
        name := value;
        return "Hello, " # name # "!";
    };

    public shared query func peek() : async Text {
        return name;
    };
};

Using QueryBuilder in Kotlin.

Using UpdateBuilder in Kotlin.

Last updated