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?

qbsp
  • 4,367
  • 2
  • 15
  • 26
rexzhao
  • 31
  • 2
  • 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 07:44
  • the DEFAULT_TO_CURRENT_BLOCK_VALUE value is -1 – rexzhao May 16 '18 at 07:50
  • the mean is when i call getbalanceat it can not receive anything ....... – rexzhao May 16 '18 at 07:50
  • Are you fully synced? – ligi May 16 '18 at 07:52
  • i am sure cause i don't known how to add event in android light client so have to use this method to call frequently – rexzhao May 16 '18 at 07:53
  • 1
    You cout use subscirbeNewHead like this: https://github.com/walleth/walleth/blob/master/app/src/withGeth/java/org/walleth/geth/services/GethLightEthereumService.kt#L168 How did you verify you are fully synced? – ligi May 16 '18 at 07:58
  • i need to call about balanceof and other 5 self contract method ..........your mean i can put all of the request method in the newheadhandle function? – rexzhao May 16 '18 at 08:03
  • sure - it is just a trigger - you can put everything in there - but really depends on your use-case – ligi May 16 '18 at 08:16
  • You are very welcome - good luck and let me know when you run into problems – ligi May 16 '18 at 08:23

0 Answers0