Android SDK for IndieSquare API written in Java, further api documentation can be found here
Download the indie_core-release.aar file from the releases section and add it to your project. You can also download the source code and build/run the example project in MainActivity.java (make sure apply plugin: 'com.android.application' is set the app gradle)
The included project contains the usage, (all results are logged in logcat)
Full usage can be seen in the example project included, specifically in the MainActivity.java (all results are logged in the console via logcat)
First initialize IndieCore in your main viewcontroller and wait for callback
String apiKey = "9dc6v7b6ba8262e153ca2df730d3c317"; //use your own apikey if you have one
ic = new IndieCore(this, apiKey, false, new IndieCore.CallbackObject() {
@Override
public void onFinished(IndieCoreError error, JSONObject result) {
if (error != null) {
Log.i("TAG", "initiated");
} else {
Log.i("TAG", "initiated");
}
}
});
Create a send transaction
ic.createSend("1965areciqapsuL2hsia2yKkRLfAsH1smG", "NETX", 1.1, "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD", new IndieCore.CallbackObject() {
@Override
public void onFinished(IndieCoreError error, JSONObject result) {
if (error != null) {
Log.i("TAG", "error" + error.message);
} else {
Log.i("TAG", "response " + result);
}
}
});
Sign transaction with users installed IndieSquare Wallet You must add your apps urlscheme (represented by MYURLSCHEME) in your manifest file, so IndieSquare can return to your app after the user authorizes the signature.
ic.signTransactionWithWallet("MYURLSCHEME",unsignedTx, new IndieCore.CallbackObject() {
@Override
public void onFinished(IndieCoreError error, JSONObject result) {
if (error != null) {
Log.i("TAG", "error" + error.message);
} else {
Log.i("TAG", "sig " + result);
}
}
});
Broadcast signed transaction
ic.broadcast(signedtx, new IndieCore.CallbackObject() {
@Override
public void onFinished(IndieCoreError error, JSONObject result) {
if (error != null) {
Log.i("TAG", "error" + error.message);
} else {
Log.i("TAG", "tx " + result);
}
}
});
}
You must add your apps urlscheme (represented by MYURLSCHEME) in your plist, so IndieSquare can return to your app after users authorizes address usage.
ic.getAddressFromWallet("MYURLSCHEME", new IndieCore.CallbackObject() {
@Override
public void onFinished(IndieCoreError error, JSONObject result) {
if (error != null) {
Log.i("TAG", "error" + error.message);
} else {
Log.i("TAG", "address " + result);
}
}
});