1
mHandler = new Handler();
Runnable r = new Runnable() {
    public void run() {

            BigInt bBalance = new BigInt(0);
            try {
                Address address = new Address(addressString);
                mEthereumClient.getBalanceAt(mContext, address, DEFAULT_TO_CURRENT_BLOCK_VALUE);
            }catch (Exception e)
            {
                DerbyLog.LogError("getBalanceAt " + e.getMessage().toString());
            }

          //每隔1s循环执行run方法
          mHandler.postDelayed(this, 10000);
    }
};
mHandler.postDelayed(r,100);

this code will stop with unknown reason why?

  • What do you mean with "stop with unknown reason"? This code looks like it should work. What do you pass in for DEFAULT_TO_CURRENT_BLOCK_VALUE – ligi May 16 '18 at 7:44
  • the DEFAULT_TO_CURRENT_BLOCK_VALUE value is -1 – rexzhao May 16 '18 at 7:50
  • the mean is when i call getbalanceat it can not receive anything ....... – rexzhao May 16 '18 at 7:50
  • Are you fully synced? – ligi May 16 '18 at 7:52
  • 1
    You cout use subscirbeNewHead like this: github.com/walleth/walleth/blob/master/app/src/withGeth/java/… How did you verify you are fully synced? – ligi May 16 '18 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.