├── 1.0 ├── mlt-demoapp-android.tgz └── mlt-release.aar ├── 1.1 ├── mlt-demoapp-android.tgz └── mlt-release.aar └── README.md /1.0/mlt-demoapp-android.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mineralt/mobile-miner-sdk-android/74a295768991ff76ca70c0c2e88054fd9264ebe4/1.0/mlt-demoapp-android.tgz -------------------------------------------------------------------------------- /1.0/mlt-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mineralt/mobile-miner-sdk-android/74a295768991ff76ca70c0c2e88054fd9264ebe4/1.0/mlt-release.aar -------------------------------------------------------------------------------- /1.1/mlt-demoapp-android.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mineralt/mobile-miner-sdk-android/74a295768991ff76ca70c0c2e88054fd9264ebe4/1.1/mlt-demoapp-android.tgz -------------------------------------------------------------------------------- /1.1/mlt-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mineralt/mobile-miner-sdk-android/74a295768991ff76ca70c0c2e88054fd9264ebe4/1.1/mlt-release.aar -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![N|Solid](http://g.recordit.co/03LNErPtVg.gif)](https://mineralt.io/) 2 | 3 | # Mobile Miner SDK for Android by Mineralt Team 4 | 5 | [![N|Solid](https://mineralt.io/img/landing/newfeatures-01.png)](https://mineralt.io/) 6 | 7 | **Note: you must have Mineralt account to use this SDK. It's free - mineralt.io/register.** 8 | 9 | ## Contents 10 | Mineralt Miner SDK distribution contains two files: 11 | * `mlt-release.aar`: Android library (SDK) for mobile miner 12 | * `mlt-demoapp-android.tgz`: Example Android application which uses MinerAlt SDK. 13 | 14 | 15 | ## Building and running example mobile miner application 16 | * Unpack example application archive: `tar xvfz mlt-demoapp-android.tgz` 17 | * Open `mlt-demoapp-android` in Android studio. It will complain about missing `mlt-release` dependency. Now, do File->New Module, 18 | choose `Import .JAR/.AAR file`, select SDK .AAR file and use `mlt-release` as imported module name (this is the default). 19 | * Choose 'release' build flavor, build application and run it on emulator or on your test device. That's it! 20 | 21 | ## Using mobile miner SDK for Android in your own application 22 | 23 | **Note: before using the Mineralt mobile miner SDK, you must register on mineralt.io/register and obtain your "Miner ID" on the Script page. For that add "Source" on the Script page and check last column in the "All traffic sources for mining" table.** 24 | 25 | [![N|Solid](http://g.recordit.co/5IKzp17SFc.gif)](https://mineralt.io/site) 26 | 27 | To add Mineralt mobile miner SDK to your Android application, do the following: 28 | * File->New Module, choose 'Import .JAR/.AAR file`, select SDK .AAR file and use `mlt-release` as imported module name (this is the default). 29 | * Add the following to the `dependencies` section of `build.gradle` of your application: 30 | ``` 31 | implementation 'com.neovisionaries:nv-websocket-client:2.4' 32 | implementation project(':mlt-release') 33 | ``` 34 | Now, you can use the API. 35 | 36 | ## Mobile miner API reference 37 | 38 | [![N|Solid](https://mineralt.io/img/landing/newfeatures-02.png)]() 39 | 40 | API reference is provided below. 41 | The steps to use Mineralt mobile mining library are: 42 | * import package: `import package blue.analytics.mlt.Mlt;` 43 | * create Mlt instance: `Mlt mlt = Mlt.getInstance(context, "minerid");`. The first argument is Android activity or application Context. 44 | For the second argument, use Miner ID provided by MinerAlt Web console. 45 | * If you want to pass more parameters, you can use Bundle as a second parameter; bundle keys are defined as MPARAM_* below. 46 | * start miner, if necessary (if MPARAM_AUTOSTART is true, miner will start automatically): `mlt.setRunning(true)`. 47 | 48 | CPU load can be set both from MinerAlt Web console, or by specifying MPARAM_LOAD (1..100). Note that Mineralt Web console setting 49 | overrides local value. If you want to use local value, don't specify explicit load in Mineralt Web console. 50 | 51 | You typically will want to stop miner in `onPause()` of your activity/service, and start it again in `onResume()`. Otherwise, 52 | users will probably complain about background task which eats their battery. As a compromise, you may want to post delayed Runnable in 53 | `onPause()` which will stop miner after few minuntes in background. 54 | 55 | If you need to know changes of miner state, use `RunState` callback; possible `runState` values are defined ad 'MLT_*'. 56 | 57 | By default, miner will stop (and will not start) if battery level is below 20%. You can change this with `MPARAM_MINBATT`, 58 | but it is not recommended (20% is reasonable default). 59 | 60 | ```java 61 | public abstract class Mlt { 62 | static public final int MLT_RUNNING = 0; // Miner is connected and running 63 | static public final int MLT_STOPPED = 1; // Miner stopped by setRunning(false) 64 | static public final int MLT_NOT_CONNECTED = 2; // Can't connect to server 65 | static public final int MLT_LOWBATT = 3; // Miner stopped because of low battery 66 | 67 | static public final String MPARAM_MID = "mid"; // MinerID (ascii alphanumeric string) 68 | static public final String MPARAM_LOAD = "load"; // (int) Load factor, optional 69 | static public final String MPARAM_URL = "url"; // Server URL, optional 70 | static public final String MPARAM_AUTOSTART = "autostart"; // (boolean) auto start on getInstance(), default=true 71 | static public final String MPARAM_MINBATT = "minbatt"; // (int) Minimum battery level when miner will stop 72 | 73 | /* Miner run state callback, runState=MLT_* */ 74 | public interface RunState { 75 | void runStateChanged(int runState); 76 | } 77 | /* Set run state change callback */ 78 | public abstract void setRunStateCallback(RunState cb); 79 | 80 | /* Start/stop miner */ 81 | public abstract void setRunning(boolean run); 82 | 83 | /* Current miner run state */ 84 | public abstract int runState(); 85 | 86 | /* Hashes per second for the current session */ 87 | public abstract int getHPS(); 88 | 89 | /* Number of hashes for the current session */ 90 | public abstract int getHashes(); 91 | 92 | /* Get ABI string (CPU, number of cores) */ 93 | public abstract String getAbiInfo(); 94 | 95 | /* Miner version ID */ 96 | public abstract int getVersionInfo(); 97 | 98 | /* Create instance with default parameters: load=30 (or taken from server), 99 | * autostart=true, minbatt=20 100 | */ 101 | public static Mlt getInstance(Context ctx, String minerid); 102 | 103 | /* Create new instance, with parameters passed in bundle. Bundle keys are 104 | * defined as MPARAM_* 105 | */ 106 | public static Mlt getInstance(Context ctx, Bundle params); 107 | 108 | /* Set/change parameters. Note that if any parameter except 'load' is changed, 109 | * miner will reconnect to server. 110 | */ 111 | public abstract void setParams(Bundle params); 112 | } 113 | ``` 114 | --------------------------------------------------------------------------------