'connecting to metamask wallet in android app project

Please is there any way to connect an android app written in Java or kotlin to a metmask wallet, I think the metamask mobile sdk on github is just for react native projects. Any help will be highly appreciated.



Solution 1:[1]

These kotlin library by walletConnect and trustwallet might be helpful to you https://github.com/WalletConnect/kotlin-walletconnect-lib\ https://github.com/trustwallet/wallet-connect-kotlin

Do check there demo app https://github.com/WalletConnect/kotlin-walletconnect-lib/blob/master/sample/app/src/main/java/io/walletconnect/example/MainActivity.kt

https://github.com/trustwallet/wallet-connect-kotlin/blob/master/app/src/main/java/com/trustwallet/walletconnect/sample/MainActivity.kt

val peerMeta = WCPeerMeta(name = "App name", url = "https://website.com")
val string = "wc:..."
val session = WCSession.from(string) ?: throw InvalidSessionError // invalid session
// handle session
wcClient.connect(wcSession, peerMeta)

    val wcClient = WCClient(GsonBuilder(), okHttpClient)

wcClient.onDisconnect = { _, _ -> 
    onDisconnect() 
}

wcClient.onSessionRequest = { _, peer -> 
    // ask for user consent
}

wcClient.onDisconnect = { _, _ -> 
    // handle disconnect
}
wcClient.onFailure = { t -> 
    // handle failure
}
wcClient.onGetAccounts = { id -> 
    // handle get_accounts
}

wcClient.onEthSign = { id, message -> 
    // handle eth_sign, personal_sign, eth_signTypedData
}
wcClient.onEthSignTransaction = { id, transaction -> 
    // handle eth_signTransaction
}
wcClient.onEthSendTransaction = { id, transaction -> 
    // handle eth_sendTransaction
}

wcClient.onSignTransaction = { id, transaction -> 
    // handle bnb_sign
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 saurabh